mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
tga: memset the whole palette array, not only the palette_size
This commit is contained in:
parent
0db5c89c5f
commit
bcce48012e
@ -201,16 +201,17 @@ static bool LoadTGA(QDataStream &s, const TgaHeader &tga, QImage &img)
|
||||
}
|
||||
|
||||
// Read palette.
|
||||
char palette[768];
|
||||
static const int max_palette_size = 768;
|
||||
char palette[max_palette_size];
|
||||
if (info.pal) {
|
||||
// @todo Support palettes in other formats!
|
||||
const int size = 3 * tga.colormap_length;
|
||||
const int dataRead = s.readRawData(palette, size);
|
||||
const int palette_size = 3 * tga.colormap_length;
|
||||
const int dataRead = s.readRawData(palette, palette_size);
|
||||
if (dataRead < 0) {
|
||||
return false;
|
||||
}
|
||||
if (dataRead < size) {
|
||||
memset(&palette[dataRead], 0, size - dataRead);
|
||||
if (dataRead < max_palette_size) {
|
||||
memset(&palette[dataRead], 0, max_palette_size - dataRead);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user