diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 11:31:14 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-02-20 16:11:02 +0100 |
commit | 14f1ec186f87ce50037044ccb079463676518ec5 (patch) | |
tree | 7e0918d1889cc93d52c5e996e79a733b2728e37b /src/widgets | |
parent | a99d7cf37213f86c8be55fc80a9785ec9a0d382d (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 'src/widgets')
-rw-r--r-- | src/widgets/effects/qpixmapfilter.cpp | 18 | ||||
-rw-r--r-- | src/widgets/styles/qstyleanimation.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qeffects.cpp | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp index 1f899c2660..705871719f 100644 --- a/src/widgets/effects/qpixmapfilter.cpp +++ b/src/widgets/effects/qpixmapfilter.cpp @@ -784,11 +784,11 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) dest.setDevicePixelRatio(source.devicePixelRatioF()); const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); - int sx = srcImage.bytesPerLine(); - int sx2 = sx << 1; + qsizetype sx = srcImage.bytesPerLine(); + qsizetype sx2 = sx << 1; uchar *dst = reinterpret_cast<uchar*>(dest.bits()); - int dx = dest.bytesPerLine(); + qsizetype dx = dest.bytesPerLine(); int ww = dest.width(); int hh = dest.height(); @@ -806,11 +806,11 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) dest.setDevicePixelRatio(source.devicePixelRatioF()); const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits()); - int sx = srcImage.bytesPerLine(); - int sx2 = sx << 1; + qsizetype sx = srcImage.bytesPerLine(); + qsizetype sx2 = sx << 1; uchar *dst = reinterpret_cast<uchar*>(dest.bits()); - int dx = dest.bytesPerLine(); + qsizetype dx = dest.bytesPerLine(); int ww = dest.width(); int hh = dest.height(); @@ -843,11 +843,11 @@ Q_WIDGETS_EXPORT QImage qt_halfScaled(const QImage &source) dest.setDevicePixelRatio(source.devicePixelRatioF()); const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits()); - int sx = srcImage.bytesPerLine() >> 2; - int sx2 = sx << 1; + qsizetype sx = srcImage.bytesPerLine() >> 2; + qsizetype sx2 = sx << 1; quint32 *dst = reinterpret_cast<quint32*>(dest.bits()); - int dx = dest.bytesPerLine() >> 2; + qsizetype dx = dest.bytesPerLine() >> 2; int ww = dest.width(); int hh = dest.height(); diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index b9202eae69..1c1158ab10 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -266,7 +266,7 @@ static QImage blendedImage(const QImage &start, const QImage &end, float alpha) const int ia = 256 - a; const int sw = start.width(); const int sh = start.height(); - const int bpl = start.bytesPerLine(); + const qsizetype bpl = start.bytesPerLine(); switch (start.depth()) { case 32: { diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp index ee4095cb36..5cb8bb3c50 100644 --- a/src/widgets/widgets/qeffects.cpp +++ b/src/widgets/widgets/qeffects.cpp @@ -305,7 +305,7 @@ void QAlphaWidget::alphaBlend() const int sw = frontImage.width(); const int sh = frontImage.height(); - const int bpl = frontImage.bytesPerLine(); + const qsizetype bpl = frontImage.bytesPerLine(); switch(frontImage.depth()) { case 32: { |