From 8d5ae9bca2cbe8c5a7f764b8ba325f79c0bbfe62 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 26 Mar 2010 10:06:50 +0100 Subject: Safeguard the colortable access when converting corrupted indexed8 Fixes: QTBUG-5510 Reviewed-by: Eskil --- src/gui/image/qimage.cpp | 4 ++-- 1 file 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(tableSize, *b++)); src_data += src->bytes_per_line; dest_data += dest->bytes_per_line; -- cgit v0.12