Commit 1530c145 authored by Manish Singh's avatar Manish Singh Committed by Manish Singh
Browse files

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.
parent 188ceabf
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
......
......@@ -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;
}
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment