From 82fd3665ff3750edc9b89eaa327ff80510f25485 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 10 Feb 2006 19:01:02 +0000 Subject: [PATCH] Always check for NULL when using callbacks. (#330563, Benjamin Otte) 2006-02-10 Matthias Clasen * io-jpeg.c: * io-png.c: * io-pnm.c: * io-tiff.c: * io-xbm.c: * io-xpm.c: Always check for NULL when using callbacks. (#330563, Benjamin Otte) --- gdk-pixbuf/ChangeLog | 10 ++++++++++ gdk-pixbuf/io-jpeg.c | 20 +++++++++++--------- gdk-pixbuf/io-png.c | 2 +- gdk-pixbuf/io-pnm.c | 9 +++++---- gdk-pixbuf/io-tiff.c | 4 ++-- gdk-pixbuf/io-xbm.c | 5 +++-- gdk-pixbuf/io-xpm.c | 10 ++++++---- 7 files changed, 38 insertions(+), 22 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index e8695d4469..7ee480fbf3 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,13 @@ +2006-02-10 Matthias Clasen + + * io-jpeg.c: + * io-png.c: + * io-pnm.c: + * io-tiff.c: + * io-xbm.c: + * io-xpm.c: Always check for NULL when using callbacks. + (#330563, Benjamin Otte) + 2006-01-25 Matthias Clasen * === Released 2.8.11 === diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c index 84376d51ba..96b3453b04 100644 --- a/gdk-pixbuf/io-jpeg.c +++ b/gdk-pixbuf/io-jpeg.c @@ -595,12 +595,13 @@ gdk_pixbuf__jpeg_image_load_lines (JpegProgContext *context, context->dptr += nlines * context->pixbuf->rowstride; /* send updated signal */ - (* context->updated_func) (context->pixbuf, - 0, - cinfo->output_scanline - 1, - cinfo->image_width, - nlines, - context->user_data); + if (context->updated_func) + (* context->updated_func) (context->pixbuf, + 0, + cinfo->output_scanline - 1, + cinfo->image_width, + nlines, + context->user_data); } return TRUE; @@ -745,9 +746,10 @@ gdk_pixbuf__jpeg_image_load_increment (gpointer data, context->dptr = context->pixbuf->pixels; /* Notify the client that we are ready to go */ - (* context->prepared_func) (context->pixbuf, - NULL, - context->user_data); + if (context->prepared_func) + (* context->prepared_func) (context->pixbuf, + NULL, + context->user_data); } else if (!context->did_prescan) { int rc; diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c index 25a2bb6060..f4e1ba567d 100644 --- a/gdk-pixbuf/io-png.c +++ b/gdk-pixbuf/io-png.c @@ -517,7 +517,7 @@ gdk_pixbuf__png_image_load_increment(gpointer context, lc->error = NULL; return FALSE; } else { - if (lc->first_row_seen_in_chunk >= 0) { + if (lc->first_row_seen_in_chunk >= 0 && lc->update_func) { /* We saw at least one row */ gint pass_diff = lc->last_pass_seen_in_chunk - lc->first_pass_seen_in_chunk; diff --git a/gdk-pixbuf/io-pnm.c b/gdk-pixbuf/io-pnm.c index 81e50a7f79..81225740ad 100644 --- a/gdk-pixbuf/io-pnm.c +++ b/gdk-pixbuf/io-pnm.c @@ -1015,9 +1015,10 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data, context->rowstride = context->pixbuf->rowstride; /* Notify the client that we are ready to go */ - (* context->prepared_func) (context->pixbuf, - NULL, - context->user_data); + if (context->prepared_func) + (* context->prepared_func) (context->pixbuf, + NULL, + context->user_data); } /* if we got here we're reading image data */ @@ -1028,7 +1029,7 @@ gdk_pixbuf__pnm_image_load_increment (gpointer data, break; } else if (retval == PNM_FATAL_ERR) { return FALSE; - } else if (retval == PNM_OK) { + } else if (retval == PNM_OK && context->updated_func) { /* send updated signal */ (* context->updated_func) (context->pixbuf, 0, diff --git a/gdk-pixbuf/io-tiff.c b/gdk-pixbuf/io-tiff.c index e874e4d910..4e81367908 100644 --- a/gdk-pixbuf/io-tiff.c +++ b/gdk-pixbuf/io-tiff.c @@ -238,7 +238,7 @@ tiff_image_parse (TIFF *tiff, TiffContext *context, GError **error) return NULL; } - if (context) + if (context && context->prepare_func) (* context->prepare_func) (pixbuf, NULL, context->user_data); #if TIFFLIB_VERSION >= 20031226 @@ -324,7 +324,7 @@ tiff_image_parse (TIFF *tiff, TiffContext *context, GError **error) _TIFFfree (rast); } - if (context) + if (context && context->update_func) (* context->update_func) (pixbuf, 0, 0, width, height, context->user_data); return pixbuf; diff --git a/gdk-pixbuf/io-xbm.c b/gdk-pixbuf/io-xbm.c index 9d808703e6..90d8120a18 100644 --- a/gdk-pixbuf/io-xbm.c +++ b/gdk-pixbuf/io-xbm.c @@ -309,7 +309,7 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error) pixels = gdk_pixbuf_get_pixels (pixbuf); row_stride = gdk_pixbuf_get_rowstride (pixbuf); - if (context) + if (context && context->prepare_func) (* context->prepare_func) (pixbuf, NULL, context->user_data); @@ -338,7 +338,8 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error) g_free (data); if (context) { - (* context->update_func) (pixbuf, 0, 0, w, h, context->user_data); + if (context->update_func) + (* context->update_func) (pixbuf, 0, 0, w, h, context->user_data); g_object_unref (pixbuf); pixbuf = NULL; } diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c index 7f020cd964..3357aab4b5 100644 --- a/gdk-pixbuf/io-xpm.c +++ b/gdk-pixbuf/io-xpm.c @@ -738,10 +738,12 @@ gdk_pixbuf__xpm_image_stop_load (gpointer data, pixbuf = gdk_pixbuf__xpm_image_load (context->file, error); if (pixbuf != NULL) { - (* context->prepare_func) (pixbuf, - NULL, - context->user_data); - (* context->update_func) (pixbuf, 0, 0, pixbuf->width, pixbuf->height, context->user_data); + if (context->prepare_func) + (* context->prepare_func) (pixbuf, + NULL, + context->user_data); + if (context->update_func) + (* context->update_func) (pixbuf, 0, 0, pixbuf->width, pixbuf->height, context->user_data); g_object_unref (pixbuf); retval = TRUE;