diff options
author | Benjamin Otte <otte@redhat.com> | 2013-02-01 19:24:32 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2013-02-01 19:24:32 +0100 |
commit | 2b3249d91b453599d3043f30f9932c5a6a09b35c (patch) | |
tree | 00d1066d94bb6295a297daa60f4add29fc2e24ef | |
parent | 1b4919298dd7692e71a642ddf959359b344fc805 (diff) | |
download | gdk-pixbuf-2b3249d91b453599d3043f30f9932c5a6a09b35c.tar.gz |
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.
-rw-r--r-- | 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 9831a1872..2ea54052f 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; |