From: Matthias Clasen Date: Fri, 18 Nov 2022 04:51:28 +0000 (-0500) Subject: gdk: Fix possible memory errors X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~92^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8c1a041104f22f0b20320c12d5bb3070b757e687;p=gtk4.git gdk: Fix possible memory errors clang complained that we may end up jumping to the cleanup code without initializing data in the jpeg code. Always initialize data to NULL to prevent that eventuality. --- diff --git a/gdk/loaders/gdkjpeg.c b/gdk/loaders/gdkjpeg.c index d0520cf9e8..6eada9d515 100644 --- a/gdk/loaders/gdkjpeg.c +++ b/gdk/loaders/gdkjpeg.c @@ -141,7 +141,7 @@ gdk_load_jpeg (GBytes *input_bytes, struct jpeg_decompress_struct info; struct error_handler_data jerr; guint width, height, stride; - unsigned char *data; + unsigned char *data = NULL; unsigned char *row[1]; GBytes *bytes; GdkTexture *texture; @@ -155,6 +155,7 @@ gdk_load_jpeg (GBytes *input_bytes, if (sigsetjmp (jerr.setjmp_buffer, 1)) { + g_free (data); jpeg_destroy_decompress (&info); return NULL; } @@ -247,7 +248,7 @@ gdk_save_jpeg (GdkTexture *texture) struct jpeg_compress_struct info; struct error_handler_data jerr; struct jpeg_error_mgr err; - guchar *data; + guchar *data = NULL; gulong size = 0; guchar *input = NULL; GdkMemoryTexture *memtex = NULL;