summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2013-02-19 14:16:20 +0100
committerBenjamin Otte <otte@redhat.com>2013-02-19 14:18:32 +0100
commit9201fcfdcafd865bc10624c5c3a12192b5eeea9a (patch)
tree482752027da7c35432cf358f16fdc43488e1e6c3
parent42ab066bfeeee5047d411bcf2e1af9c977561b7c (diff)
downloadgdk-pixbuf-9201fcfdcafd865bc10624c5c3a12192b5eeea9a.tar.gz
animation: Improve error handling
The previous code couldn't guarantee that an animation existed when there wasn't an error not could it guarantee that no animation was returned when there indeed was an error. https://bugzilla.gnome.org/show_bug.cgi?id=694148
-rw-r--r--gdk-pixbuf/gdk-pixbuf-animation.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/gdk-pixbuf/gdk-pixbuf-animation.c b/gdk-pixbuf/gdk-pixbuf-animation.c
index 38d30f58c..e39a5927c 100644
--- a/gdk-pixbuf/gdk-pixbuf-animation.c
+++ b/gdk-pixbuf/gdk-pixbuf-animation.c
@@ -218,39 +218,41 @@ gdk_pixbuf_animation_new_from_file (const char *filename,
guchar buffer[4096];
size_t length;
gpointer context;
+ gboolean success;
+ success = FALSE;
animation = NULL;
fseek (f, 0, SEEK_SET);
context = image_module->begin_load (NULL, prepared_notify, NULL, &animation, error);
-
- if (!context) {
- error = NULL;
- goto fail_progressive_load;
- }
+ if (!context)
+ goto fail_begin_load;
while (!feof (f) && !ferror (f)) {
length = fread (buffer, 1, sizeof (buffer), f);
if (length > 0) {
if (!image_module->load_increment (context, buffer, length, error)) {
error = NULL;
- goto fail_progressive_load;
+ goto fail_load_increment;
}
}
}
-fail_progressive_load:
+ /* If there was no error, there must be an animation that was successfully loaded */
+ g_assert (animation);
+ success = TRUE;
+
+fail_load_increment:
+ if (!image_module->stop_load (context, error))
+ success = FALSE;
+
+fail_begin_load:
fclose (f);
- if (context && !image_module->stop_load (context, error)) {
- if (animation)
- g_object_unref (animation);
- g_free (display_name);
- return NULL;
+ if (!success && animation) {
+ g_object_unref (animation);
+ animation = NULL;
}
-
- /* If there was no error, there must be an animation that was successfully loaded */
- g_assert (animation);
} else {
GdkPixbuf *pixbuf;