summaryrefslogtreecommitdiff
path: root/gdk-pixbuf/io-jpeg.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-12-16 18:17:36 -0500
committerMatthias Clasen <mclasen@redhat.com>2013-12-16 18:17:36 -0500
commit33182adcd67562b78220c8e263fff6a7bd51b0a1 (patch)
treeb8f58859b4733ac2931a9818189e8038fedb255f /gdk-pixbuf/io-jpeg.c
parentf26ed67c77d4c5ee48fc63f7738508979da0cd5c (diff)
downloadgdk-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.
Diffstat (limited to 'gdk-pixbuf/io-jpeg.c')
-rw-r--r--gdk-pixbuf/io-jpeg.c14
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);