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:
parent
34f980108d
commit
bb3bf0ae5b
1 changed files with 20 additions and 2 deletions
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue