diff options
author | Bastien Nocera <hadess@hadess.net> | 2019-03-01 12:18:06 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2019-03-01 12:18:06 +0100 |
commit | f7ef901d25722c42d85f486b88d2644a193a6609 (patch) | |
tree | abdd965617b37f042cc60b37a1c1c8c0a3eafb64 /gdk-pixbuf | |
parent | 76f929158e48f4a1c222c816a65f242c290dff20 (diff) | |
download | gdk-pixbuf-f7ef901d25722c42d85f486b88d2644a193a6609.tar.gz |
xpm: Simplify error path
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r-- | gdk-pixbuf/io-xpm.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/gdk-pixbuf/io-xpm.c b/gdk-pixbuf/io-xpm.c index 0da5b241b..8a4ceee71 100644 --- a/gdk-pixbuf/io-xpm.c +++ b/gdk-pixbuf/io-xpm.c @@ -459,7 +459,7 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl GHashTable *color_hash; XPMColor *colors, *color, *fallbackcolor; guchar *pixtmp; - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf = NULL; gint rowstride; fallbackcolor = NULL; @@ -556,10 +556,7 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_CORRUPT_IMAGE, _("Cannot read XPM colormap")); - g_hash_table_destroy (color_hash); - g_free (name_buf); - g_free (colors); - return NULL; + goto out; } color = &colors[cnt]; @@ -594,10 +591,7 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY, _("Cannot allocate memory for loading XPM image")); - g_hash_table_destroy (color_hash); - g_free (colors); - g_free (name_buf); - return NULL; + goto out; } rowstride = gdk_pixbuf_get_rowstride (pixbuf); @@ -646,6 +640,14 @@ pixbuf_create_from_xpm (const gchar * (*get_buf) (enum buf_op op, gpointer handl } return pixbuf; + +out: + g_hash_table_destroy (color_hash); + g_free (colors); + g_free (name_buf); + + g_clear_object (&pixbuf); + return NULL; } /* Shared library entry point for file loading */ |