ras: fix crash on broken files

Replace QVector::operator[] with QVector::value() since we can't know for
sure the values will be on range so use value() that gives us a 0 if the
index is not on range

oss-fuzz/13462
This commit is contained in:
Albert Astals Cid 2019-03-01 23:32:33 +01:00
parent 297b168a52
commit 20100a1e0e

View File

@ -164,9 +164,9 @@ static bool LoadRAS(QDataStream &s, const RasHeader &ras, QImage &img)
quint8 red, green, blue;
for (quint32 y = 0; y < ras.Height; y++) {
for (quint32 x = 0; x < ras.Width; x++) {
red = palette[(int)input[y * ras.Width + x]];
green = palette[(int)input[y * ras.Width + x] + (ras.ColorMapLength / 3)];
blue = palette[(int)input[y * ras.Width + x] + 2 * (ras.ColorMapLength / 3)];
red = palette.value((int)input[y * ras.Width + x]);
green = palette.value((int)input[y * ras.Width + x] + (ras.ColorMapLength / 3));
blue = palette.value((int)input[y * ras.Width + x] + 2 * (ras.ColorMapLength / 3));
img.setPixel(x, y, qRgb(red, green, blue));
}
}