diff options
author | Manish Singh <yosh@gimp.org> | 2002-01-20 04:52:47 +0000 |
---|---|---|
committer | Manish Singh <yosh@src.gnome.org> | 2002-01-20 04:52:47 +0000 |
commit | 1530c14531f8bbfbd0bf3b577ec312244982e3d2 (patch) | |
tree | 238d650b08aca657aece4479bc75e6a073ecb0e7 /gdk-pixbuf | |
parent | 188ceabf8bfdd74161acc1a67f9856045f79796b (diff) | |
download | gtk+-1530c14531f8bbfbd0bf3b577ec312244982e3d2.tar.gz |
Made sure all the error cases involving jpeg or png load/saves clean
Sat Jan 19 20:49:20 2002 Manish Singh <yosh@gimp.org>
* io-jpeg.c, io-png.c: Made sure all the error cases involving
jpeg or png load/saves clean themselves up properly. Marked some
variables needed for cleanup volatile so they aren't clobbered by
setjmp.
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/ChangeLog | 7 | ||||
-rw-r--r-- | gdk-pixbuf/io-jpeg.c | 8 | ||||
-rw-r--r-- | gdk-pixbuf/io-png.c | 23 |
3 files changed, 27 insertions, 11 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index b548f247ab..3853731e6b 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,10 @@ +Sat Jan 19 20:49:20 2002 Manish Singh <yosh@gimp.org> + + * io-jpeg.c, io-png.c: Made sure all the error cases involving + jpeg or png load/saves clean themselves up properly. Marked some + variables needed for cleanup volatile so they aren't clobbered by + setjmp. + Fri Jan 11 18:05:07 2002 Owen Taylor <otaylor@redhat.com> * pixops/pixops.c: Fix integer overflow for the values diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c index 0cc66cdbf7..87bfbe185c 100644 --- a/gdk-pixbuf/io-jpeg.c +++ b/gdk-pixbuf/io-jpeg.c @@ -182,7 +182,7 @@ static GdkPixbuf * gdk_pixbuf__jpeg_image_load (FILE *f, GError **error) { gint w, h, i; - guchar *pixels = NULL; + guchar * volatile pixels = NULL; guchar *dptr; guchar *lines[4]; /* Used to expand rows, via rec_outbuf_height, * from the header file: @@ -203,7 +203,7 @@ gdk_pixbuf__jpeg_image_load (FILE *f, GError **error) if (sigsetjmp (jerr.setjmp_buffer, 1)) { /* Whoops there was a jpeg error */ if (pixels) - free (pixels); + g_free (pixels); jpeg_destroy_decompress (&cinfo); return NULL; @@ -719,7 +719,7 @@ gdk_pixbuf__jpeg_image_save (FILE *f, cinfo.err = jpeg_std_error (&(jerr.pub)); if (sigsetjmp (jerr.setjmp_buffer, 1)) { jpeg_destroy_compress (&cinfo); - free (buf); + g_free (buf); return FALSE; } @@ -754,7 +754,7 @@ gdk_pixbuf__jpeg_image_save (FILE *f, /* finish off */ jpeg_finish_compress (&cinfo); - free (buf); + g_free (buf); return TRUE; } diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c index d4cd962289..aedd0be18b 100644 --- a/gdk-pixbuf/io-png.c +++ b/gdk-pixbuf/io-png.c @@ -211,8 +211,8 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error) gboolean failed = FALSE; gint i, ctype, bpp; png_uint_32 w, h; - png_bytepp rows; - guchar *pixels; + png_bytepp volatile rows = NULL; + guchar * volatile pixels = NULL; gint num_texts; gchar **options = NULL; @@ -236,6 +236,12 @@ gdk_pixbuf__png_image_load (FILE *f, GError **error) } if (setjmp (png_ptr->jmpbuf)) { + if (rows) + g_free (rows); + + if (pixels) + g_free (pixels); + png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); return NULL; } @@ -728,6 +734,7 @@ gdk_pixbuf__png_image_save (FILE *f, int has_alpha; int bpc; int num_keys; + gboolean success = TRUE; num_keys = 0; @@ -802,12 +809,12 @@ gdk_pixbuf__png_image_save (FILE *f, info_ptr = png_create_info_struct (png_ptr); if (info_ptr == NULL) { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; + success = FALSE; + goto cleanup; } if (setjmp (png_ptr->jmpbuf)) { - png_destroy_write_struct (&png_ptr, (png_infopp) NULL); - return FALSE; + success = FALSE; + goto cleanup; } if (num_keys > 0) { @@ -842,6 +849,8 @@ gdk_pixbuf__png_image_save (FILE *f, } png_write_end (png_ptr, info_ptr); + +cleanup: png_destroy_write_struct (&png_ptr, (png_infopp) NULL); if (num_keys > 0) { @@ -850,7 +859,7 @@ gdk_pixbuf__png_image_save (FILE *f, g_free (text_ptr); } - return TRUE; + return success; } |