summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qimagescale.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2015-07-25 14:43:14 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-08-10 10:22:36 +0000
commitbec8c726bf76cda94f73efc76fef6bcea5bc133a (patch)
treeba11819dd959b98825a0b4304e4bbca7b00ee943 /src/gui/painting/qimagescale.cpp
parent9fe0ff082c7edc31c1949f55044adde32067bfa0 (diff)
Fix out-of-buffer read on image upscale
Avoid reading from the next pixel when the sample is fully based on the current pixel. This is particular important for the last pixel in an image when the next pixel might be outside the image buffer. Change-Id: I3607f9c6c332d11ff944ca35d216d417368f9fd5 Task-number: QTBUG-47228 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/gui/painting/qimagescale.cpp')
-rw-r--r--src/gui/painting/qimagescale.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/painting/qimagescale.cpp b/src/gui/painting/qimagescale.cpp
index 867c64c5e0..2f85e90c49 100644
--- a/src/gui/painting/qimagescale.cpp
+++ b/src/gui/painting/qimagescale.cpp
@@ -312,7 +312,10 @@ static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest,
for (int x = dxx; x < end; x++) {
const unsigned int *pix = sptr + xpoints[x];
const int xap = xapoints[x];
- *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap);
+ if (xap > 0)
+ *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap);
+ else
+ *dptr = pix[0];
dptr++;
}
}