summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 11:31:14 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-02-20 16:11:02 +0100
commit14f1ec186f87ce50037044ccb079463676518ec5 (patch)
tree7e0918d1889cc93d52c5e996e79a733b2728e37b /tests
parenta99d7cf37213f86c8be55fc80a9785ec9a0d382d (diff)
Make bytes-per-line safe for int overflow
Goes through the Qt code and make sure bytes-per-line calculations are safe when they are too big for 32bit integers. Change-Id: I88b2d74b3da82e91407d316aa932a4a37587c0cf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp4
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp2
-rw-r--r--tests/baselineserver/shared/baselineprotocol.cpp4
3 files changed, 5 insertions, 5 deletions
diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
index aaa8475c74..247f6443c1 100644
--- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
+++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp
@@ -94,8 +94,8 @@ private:
static void initializePadding(QImage *image)
{
- int effectiveBytesPerLine = (image->width() * image->depth() + 7) / 8;
- int paddingBytes = image->bytesPerLine() - effectiveBytesPerLine;
+ qsizetype effectiveBytesPerLine = (qsizetype(image->width()) * image->depth() + 7) / 8;
+ qsizetype paddingBytes = image->bytesPerLine() - effectiveBytesPerLine;
if (paddingBytes == 0)
return;
for (int y = 0; y < image->height(); ++y) {
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 485a0b0f93..bd287eb225 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -2136,7 +2136,7 @@ void tst_QTextEdit::compareWidgetAndImage(QTextEdit &widget, const QString &imag
QCOMPARE(image.depth(), 32);
QCOMPARE(original.depth(), image.depth());
- const int bytesPerLine = image.bytesPerLine();
+ const qsizetype bytesPerLine = image.bytesPerLine();
const int width = image.width();
const int height = image.height();
diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp
index 9e5321cb1b..d11369f3d2 100644
--- a/tests/baselineserver/shared/baselineprotocol.cpp
+++ b/tests/baselineserver/shared/baselineprotocol.cpp
@@ -223,8 +223,8 @@ quint32 *pb); /* IN: more seed OUT: secondary hash value */
quint64 ImageItem::computeChecksum(const QImage &image)
{
QImage img(image);
- const int bpl = img.bytesPerLine();
- const int padBytes = bpl - (img.width() * img.depth() / 8);
+ const qsizetype bpl = img.bytesPerLine();
+ const int padBytes = bpl - (qsizetype(img.width()) * img.depth() / 8);
if (padBytes) {
uchar *p = img.bits() + bpl - padBytes;
const int h = img.height();