mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-19 12:14:20 -04:00
tga: Fix Use-of-uninitialized-value on broken files
oss-fuzz/12776
This commit is contained in:
@ -204,7 +204,11 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
|
||||
char palette[768];
|
||||
if (info.pal) {
|
||||
// @todo Support palettes in other formats!
|
||||
s.readRawData(palette, 3 * tga.colormap_length);
|
||||
const int size = 3 * tga.colormap_length;
|
||||
const int dataRead = s.readRawData(palette, size);
|
||||
if (dataRead < size) {
|
||||
memset(&palette[dataRead], 0, size - dataRead);
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate image.
|
||||
@ -255,7 +259,10 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
|
||||
}
|
||||
} else {
|
||||
// Read raw image.
|
||||
s.readRawData((char *)image, size);
|
||||
const int dataRead = s.readRawData((char *)image, size);
|
||||
if (dataRead < size) {
|
||||
memset(&image[dataRead], 0, size - dataRead);
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
|
Reference in New Issue
Block a user