summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2019-03-01 12:18:06 +0100
committerBastien Nocera <hadess@hadess.net>2019-03-01 12:18:06 +0100
commitf7ef901d25722c42d85f486b88d2644a193a6609 (patch)
treeabdd965617b37f042cc60b37a1c1c8c0a3eafb64
parent76f929158e48f4a1c222c816a65f242c290dff20 (diff)
downloadgdk-pixbuf-f7ef901d25722c42d85f486b88d2644a193a6609.tar.gz
xpm: Simplify error path
-rw-r--r--gdk-pixbuf/io-xpm.c20
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 */