plug-ins: Allocate memory in PAA plug-in

Per mzfr, we should dynamically allocate memory
for the PAA plug-in pixel data rather than rely on the image
being small enough for an array to store its information.
This commit is contained in:
Alx Sa 2026-03-20 12:24:47 +00:00
parent 34f980108d
commit bb3bf0ae5b

View file

@ -332,14 +332,31 @@ load_image (GFile *file,
guchar *uncompressed_data;
gint estimated_size;
guint dims = (guint32) width * height;
guchar pixels[dims * 4];
guchar *pixels;
pixels = g_try_malloc0 (dims * 4);
if (pixels == NULL)
{
g_set_error (error, G_FILE_ERROR, 0,
_("Memory could not be allocated."));
g_object_unref (buffer);
return NULL;
}
if (paa_type != RGBA_8888)
estimated_size = dims * 2;
else
estimated_size = dims * 4;
uncompressed_data = g_malloc0 (estimated_size);
uncompressed_data = g_try_malloc0 (estimated_size);
if (uncompressed_data == NULL)
{
g_set_error (error, G_FILE_ERROR, 0,
_("Memory could not be allocated."));
g_object_unref (buffer);
return NULL;
}
if (! decode_lzss (raw_data, uncompressed_data, estimated_size))
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
@ -395,6 +412,7 @@ load_image (GFile *file,
break;
}
g_free (uncompressed_data);
g_free (pixels);
num_mipmaps++;
}