From adc808729bbd3502d05e05c3cf36b28e6355df58 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 6 Jul 2002 08:55:20 +0000 Subject: [PATCH] Handle global_error == NULL better. (tiff_image_parse): Don't trust * io-tiff.c (tiff_set_error): Handle global_error == NULL better. (tiff_image_parse): Don't trust TIFFRGBAImageBegin to set the "put" routine. (Fixes #87384) (gdk_pixbuf__tiff_image_stop_load): Don't call TIFFClose too early. --- gdk-pixbuf/ChangeLog | 9 +++++++++ gdk-pixbuf/io-tiff.c | 24 ++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 3ae28b7ff0..c750ac6629 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,12 @@ +2002-07-06 Matthias Clasen + + * io-tiff.c (tiff_set_error): Handle global_error == NULL + better. + (tiff_image_parse): Don't trust TIFFRGBAImageBegin to set + the "put" routine. (Fixes #87384) + (gdk_pixbuf__tiff_image_stop_load): Don't call TIFFClose too + early. + 2002-07-02 Matthias Clasen * io-bmp.c (grow_buffer): New function to avoid crashes diff --git a/gdk-pixbuf/io-tiff.c b/gdk-pixbuf/io-tiff.c index a8365fa961..c2d9503cb8 100644 --- a/gdk-pixbuf/io-tiff.c +++ b/gdk-pixbuf/io-tiff.c @@ -119,16 +119,20 @@ tiff_set_error (GError **error, /* Take the error message from libtiff and merge it with * some context we provide. */ + if (global_error) { g_set_error (error, GDK_PIXBUF_ERROR, error_code, - "%s%s%s", - msg, global_error ? ": " : "", global_error); + "%s%s%s", msg, ": ", global_error); - if (global_error) { g_free (global_error); global_error = NULL; } + else { + g_set_error (error, + GDK_PIXBUF_ERROR, + error_code, msg); + } } @@ -256,6 +260,14 @@ tiff_image_parse (TIFF *tiff, TiffContext *context, GError **error) return NULL; } + if (img.put.any == NULL) { + tiff_set_error (error, + GDK_PIXBUF_ERROR_FAILED, + _("Unsupported TIFF variant")); + g_object_unref (pixbuf); + return NULL; + } + if (img.isContig) { tiff_put_contig = img.put.contig; img.put.contig = put_contig; @@ -476,16 +488,20 @@ gdk_pixbuf__tiff_image_stop_load (gpointer data, if (pixbuf) g_object_unref (pixbuf); retval = pixbuf != NULL; - TIFFClose (tiff); if (global_error) { tiff_set_error (error, GDK_PIXBUF_ERROR_FAILED, _("Failed to load TIFF image")); + tiff_pop_handlers (); + retval = FALSE; } } + if (tiff) + TIFFClose (tiff); + g_assert (!global_error); g_free (context->buffer);