mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-05-28 00:30:23 -04:00
tga: fail gracefully if readRawData errors
oss-fuzz/12818
This commit is contained in:
parent
1a31500e55
commit
a51cbd865f
@ -206,6 +206,9 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
|
||||
// @todo Support palettes in other formats!
|
||||
const int size = 3 * tga.colormap_length;
|
||||
const int dataRead = s.readRawData(palette, size);
|
||||
if (dataRead < 0) {
|
||||
return false;
|
||||
}
|
||||
if (dataRead < size) {
|
||||
memset(&palette[dataRead], 0, size - dataRead);
|
||||
}
|
||||
@ -260,6 +263,10 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
|
||||
} else {
|
||||
// Read raw image.
|
||||
const int dataRead = s.readRawData((char *)image, size);
|
||||
if (dataRead < 0) {
|
||||
free(image);
|
||||
return false;
|
||||
}
|
||||
if (dataRead < size) {
|
||||
memset(&image[dataRead], 0, size - dataRead);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user