[gdk-pixbuf] animation: Fix copy/paste SEGV



commit 2b3249d91b453599d3043f30f9932c5a6a09b35c
Author: Benjamin Otte <otte redhat com>
Date:   Fri Feb 1 19:24:32 2013 +0100

    animation: Fix copy/paste SEGV
    
    The wrong variable was set, so we were returning invalid memory. Oops.
    Also fixes up the error paths to make it more obvious what happens.

 gdk-pixbuf/gdk-pixbuf-animation.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-animation.c b/gdk-pixbuf/gdk-pixbuf-animation.c
index 9831a18..2ea5405 100644
--- a/gdk-pixbuf/gdk-pixbuf-animation.c
+++ b/gdk-pixbuf/gdk-pixbuf-animation.c
@@ -217,34 +217,37 @@ gdk_pixbuf_animation_new_from_file (const char *filename,
         } else if (image_module->begin_load != NULL) {
                 guchar buffer[4096];
                 size_t length;
-                GdkPixbufAnimation *anim = NULL;
                 gpointer context;
 
+                animation = NULL;
 		fseek (f, 0, SEEK_SET);
 
-                context = image_module->begin_load (NULL, prepared_notify, NULL, &anim, error);
+                context = image_module->begin_load (NULL, prepared_notify, NULL, &animation, error);
                 
-                if (!context)
-                        return NULL;
+                if (!context || !animation) {
+                        error = NULL;
+                        goto fail_progressive_load;
+                }
                 
                 while (!feof (f) && !ferror (f)) {
                         length = fread (buffer, 1, sizeof (buffer), f);
-                        if (length > 0)
+                        if (length > 0) {
                                 if (!image_module->load_increment (context, buffer, length, error)) {
-                                        image_module->stop_load (context, NULL);
-                                        if (anim != NULL)
-                                                g_object_unref (anim);
-                                        return NULL;
+                                        error = NULL;
+                                        goto fail_progressive_load;
                                 }
+                        }
                 }
 
-                if (!image_module->stop_load (context, error)) {
-                        if (anim != NULL)
-                                g_object_unref (anim);
+fail_progressive_load:
+		fclose (f);
+
+                if (context && !image_module->stop_load (context, error)) {
+                        if (animation)
+                                g_object_unref (animation);
+                        g_free (display_name);
                         return NULL;
                 }
-
-		fclose (f);
 	} else {
 		GdkPixbuf *pixbuf;
 



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