From bb3bf0ae5bac657827f4691b71c8a7fa5177a4fd Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Fri, 20 Mar 2026 12:24:47 +0000 Subject: [PATCH] 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. --- plug-ins/common/file-paa.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/plug-ins/common/file-paa.c b/plug-ins/common/file-paa.c index 5f0ab4c612..38c52d2a29 100644 --- a/plug-ins/common/file-paa.c +++ b/plug-ins/common/file-paa.c @@ -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++; }