tga: memset dst if read fails

This commit is contained in:
Albert Astals Cid
2019-05-01 01:47:23 +02:00
parent bcce48012e
commit 96b1d7e7bc

View File

@ -257,7 +257,14 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
} else { } else {
// Raw pixels. // Raw pixels.
count *= pixel_size; count *= pixel_size;
s.readRawData(dst, count); const int dataRead = s.readRawData(dst, count);
if (dataRead < 0) {
free(image);
return false;
}
if ((uint)dataRead < count) {
memset(&dst[dataRead], 0, count - dataRead);
}
dst += count; dst += count;
} }
} }