aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktestutils/quick/visualtestutils.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2024-11-14 12:00:39 +0800
committerMitch Curtis <mitch.curtis@qt.io>2024-11-15 10:43:16 +0800
commita5412bece857c5e2742a9cc2dc2e65539416a17b (patch)
tree208f217ebb3e87f3ce77ad9ec3ac74f42ee9afb8 /src/quicktestutils/quick/visualtestutils.cpp
parent9c72d7f3dcf5179975edf759173bca5d46f566c9 (diff)
QQuickVisualTestUtils::compareImages: fail if image depth is not 32
The function would ignore the depth and read memory that it shouldn't, which can cause hard-to-diagnose failures, and heap-buffer-overflows when ASAN is enabled. Mismatches in depth can happen when optimizing images with optipng, for example, which may convert color images to grayscale. compareImages was added in 7ffea4048321b86402a9ded5255ad16ac74d0518. Pick-to: 6.5 6.8 Change-Id: Id83dcd79ae94088996ff770d90b2c1add910fb1b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/quicktestutils/quick/visualtestutils.cpp')
-rw-r--r--src/quicktestutils/quick/visualtestutils.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/quicktestutils/quick/visualtestutils.cpp b/src/quicktestutils/quick/visualtestutils.cpp
index 0942af300f..f708b815e2 100644
--- a/src/quicktestutils/quick/visualtestutils.cpp
+++ b/src/quicktestutils/quick/visualtestutils.cpp
@@ -150,6 +150,10 @@ bool QQuickVisualTestUtils::compareImages(const QImage &ia, const QImage &ib, QS
QDebug(errorMessage) << "Images are of different formats:" << ia.format() << ib.format();
return false;
}
+ if (ia.depth() != 32) {
+ QDebug(errorMessage) << "This function only supports bit depths of 32 - depth of images is:" << ia.depth();
+ return false;
+ }
int w = ia.width();
int h = ia.height();