mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
tga: Fix Use-of-uninitialized-value on broken files
oss-fuzz/12776
This commit is contained in:
parent
e7f3c0be44
commit
8b8330b0fe
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user