summaryrefslogtreecommitdiff
path: root/gdk-pixbuf/io-png.c
diff options
context:
space:
mode:
authorLarry Ewing <lewing@helixcode.com>2000-06-09 19:41:29 +0000
committerLarry Ewing <lewing@src.gnome.org>2000-06-09 19:41:29 +0000
commitb166924b0ccf6d5c3b5b36d04b1d8f7df2072ef6 (patch)
tree5d7bf93e83d27a01f9cdb72613dfca02db9fd8bb /gdk-pixbuf/io-png.c
parent40298ef908827fdde7f30a7ee18dd1d6d65c3ae4 (diff)
downloadgtk+-b166924b0ccf6d5c3b5b36d04b1d8f7df2072ef6.tar.gz
setjmp for the png error handler. It seems setting the error handling
2000-06-09 Larry Ewing <lewing@helixcode.com> * gdk-pixbuf/io-png.c (gdk_pixbuf__png_image_load_increment): setjmp for the png error handler. It seems setting the error handling functions does not avoid the jump, and so not calling setjmp was causing the incremental loader to jump into lala land. (gdk_pixbuf__png_image_begin_load): setjmp for error handling, I'm not sure this one is actually required but the docs say it must be set for every call to a png_* function. Also changed the comment to reflect the fact that setting the error handlers does _not_ avoid the longjmp.
Diffstat (limited to 'gdk-pixbuf/io-png.c')
-rw-r--r--gdk-pixbuf/io-png.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
index 4514194842..afd9ffdca2 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -220,7 +220,8 @@ gdk_pixbuf__png_image_load (FILE *f)
free_buffer, NULL);
}
-/* These avoid the setjmp()/longjmp() crap in libpng */
+/* I wish these avoided the setjmp()/longjmp() crap in libpng instead
+ just allow you to change the error reporting. */
static void png_error_callback (png_structp png_read_ptr,
png_const_charp error_msg);
@@ -299,6 +300,7 @@ gdk_pixbuf__png_image_begin_load (ModulePreparedNotifyFunc prepare_func,
/* Create the main PNG context struct */
+
lc->png_read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
lc, /* error/warning callback data */
png_error_callback,
@@ -309,6 +311,13 @@ gdk_pixbuf__png_image_begin_load (ModulePreparedNotifyFunc prepare_func,
return NULL;
}
+ if (setjmp (lc->png_read_ptr->jmpbuf)) {
+ if (lc->png_info_ptr)
+ png_destroy_read_struct(&lc->png_read_ptr, NULL, NULL);
+ g_free(lc);
+ return NULL;
+ }
+
/* Create the auxiliary context struct */
lc->png_info_ptr = png_create_info_struct(lc->png_read_ptr);
@@ -357,7 +366,11 @@ gdk_pixbuf__png_image_load_increment(gpointer context, guchar *buf, guint size)
lc->max_row_seen_in_chunk = -1;
/* Invokes our callbacks as needed */
- png_process_data(lc->png_read_ptr, lc->png_info_ptr, buf, size);
+ if (setjmp (lc->png_read_ptr->jmpbuf)) {
+ return FALSE;
+ } else {
+ png_process_data(lc->png_read_ptr, lc->png_info_ptr, buf, size);
+ }
if (lc->fatal_error_occurred)
return FALSE;
@@ -522,3 +535,7 @@ png_warning_callback(png_structp png_read_ptr,
fprintf(stderr, "Warning loading PNG: %s\n", warning_msg);
}
+
+
+
+