diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-12-16 18:17:36 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-12-16 18:17:36 -0500 |
commit | 33182adcd67562b78220c8e263fff6a7bd51b0a1 (patch) | |
tree | b8f58859b4733ac2931a9818189e8038fedb255f | |
parent | f26ed67c77d4c5ee48fc63f7738508979da0cd5c (diff) | |
download | gdk-pixbuf-33182adcd67562b78220c8e263fff6a7bd51b0a1.tar.gz |
jpeg: Consolidate error handling
Make all error paths in gdk_pixbuf__jpeg_image_load
go through the same path, so we don't forget to free
the exif data in half of them.
-rw-r--r-- | gdk-pixbuf/io-jpeg.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c index f934dffdb..ef5fdc1ec 100644 --- a/gdk-pixbuf/io-jpeg.c +++ b/gdk-pixbuf/io-jpeg.c @@ -536,7 +536,7 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error) struct error_handler_data jerr; stdio_src_ptr src; gchar *icc_profile_base64; - JpegExifContext *exif_context; + JpegExifContext *exif_context = NULL; /* setup error handler */ cinfo.err = jpeg_std_error (&jerr.pub); @@ -592,8 +592,6 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error) 8, cinfo.output_width, cinfo.output_height); if (!pixbuf) { - jpeg_destroy_decompress (&cinfo); - /* broken check for *error == NULL for robustness against * crappy JPEG library */ @@ -603,8 +601,8 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error) GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, _("Insufficient memory to load image, try exiting some applications to free memory")); } - - return NULL; + + goto out; } /* if orientation tag was found */ @@ -644,6 +642,7 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error) break; default: g_object_unref (pixbuf); + pixbuf = NULL; if (error && *error == NULL) { g_set_error (error, GDK_PIXBUF_ERROR, @@ -651,12 +650,11 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error) _("Unsupported JPEG color space (%s)"), colorspace_name (cinfo.out_color_space)); } - - jpeg_destroy_decompress (&cinfo); - return NULL; + goto out; } } +out: jpeg_finish_decompress (&cinfo); jpeg_destroy_decompress (&cinfo); jpeg_destroy_exif_context (exif_context); |