summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2010-03-26 09:06:50 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2010-03-26 09:10:56 (GMT)
commit8d5ae9bca2cbe8c5a7f764b8ba325f79c0bbfe62 (patch)
tree2ae8c609c082489a5c2d3d120453b24ac9ee8e75 /src/gui
parente7c8f5b6f2751fe3ebcecfdf26ff0dd6cbbb2512 (diff)
downloadQt-8d5ae9bca2cbe8c5a7f764b8ba325f79c0bbfe62.zip
Qt-8d5ae9bca2cbe8c5a7f764b8ba325f79c0bbfe62.tar.gz
Qt-8d5ae9bca2cbe8c5a7f764b8ba325f79c0bbfe62.tar.bz2
Safeguard the colortable access when converting corrupted indexed8
Fixes: QTBUG-5510 Reviewed-by: Eskil
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qimage.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 94307de..233c58d 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2988,19 +2988,19 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt:
colorTable.resize(256);
for (int i=0; i<256; ++i)
colorTable[i] = qRgb(i, i, i);
-
}
int w = src->width;
const uchar *src_data = src->data;
uchar *dest_data = dest->data;
+ int tableSize = colorTable.size() - 1;
for (int y = 0; y < src->height; y++) {
uint *p = (uint *)dest_data;
const uchar *b = src_data;
uint *end = p + w;
while (p < end)
- *p++ = colorTable.at(*b++);
+ *p++ = colorTable.at(qMin<int>(tableSize, *b++));
src_data += src->bytes_per_line;
dest_data += dest->bytes_per_line;