tga: don't try to read more than max_palette_size into palette

This commit is contained in:
Albert Astals Cid 2019-05-01 01:48:14 +02:00
parent 96b1d7e7bc
commit 1a9b5d6cb6

View File

@ -206,6 +206,9 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
if (info.pal) {
// @todo Support palettes in other formats!
const int palette_size = 3 * tga.colormap_length;
if (palette_size > max_palette_size) {
return false;
}
const int dataRead = s.readRawData(palette, palette_size);
if (dataRead < 0) {
return false;