[gdk-pixbuf] PNG: assert and assume that the module callbacks are non-NULL



commit 344a74e012ebdae5842b99dabd7c20174c08077d
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Nov 28 19:26:10 2017 -0600

    PNG: assert and assume that the module callbacks are non-NULL

 gdk-pixbuf/io-png.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c
index e39b1ecb7..4e99536bf 100644
--- a/gdk-pixbuf/io-png.c
+++ b/gdk-pixbuf/io-png.c
@@ -449,6 +449,10 @@ gdk_pixbuf__png_image_begin_load (GdkPixbufModuleSizeFunc size_func,
 {
         LoadContext* lc;
         
+        g_assert (size_func != NULL);
+        g_assert (prepare_func != NULL);
+        g_assert (update_func != NULL);
+
         lc = g_new0(LoadContext, 1);
         
         lc->fatal_error_occurred = FALSE;
@@ -597,9 +601,8 @@ gdk_pixbuf__png_image_load_increment(gpointer context,
                 lc->error = NULL;
                 return FALSE;
         } else {
-                if (lc->first_row_seen_in_chunk >= 0 && lc->update_func) {
+                if (lc->first_row_seen_in_chunk >= 0) {
                         gint width = gdk_pixbuf_get_width (lc->pixbuf);
-
                         /* We saw at least one row */
                         gint pass_diff = lc->last_pass_seen_in_chunk - lc->first_pass_seen_in_chunk;
                         
@@ -687,7 +690,7 @@ png_info_callback   (png_structp png_read_ptr,
         if (color_type & PNG_COLOR_MASK_ALPHA)
                 have_alpha = TRUE;
         
-        if (lc->size_func) {
+        {
                 gint w = width;
                 gint h = height;
                 (* lc->size_func) (&w, &h, lc->notify_user_data);
@@ -758,8 +761,7 @@ png_info_callback   (png_structp png_read_ptr,
 
         /* Notify the client that we are ready to go */
 
-        if (lc->prepare_func)
-                (* lc->prepare_func) (lc->pixbuf, NULL, lc->notify_user_data);
+        (* lc->prepare_func) (lc->pixbuf, NULL, lc->notify_user_data);
 
         return;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]