summaryrefslogtreecommitdiff
path: root/libappstream-glib/as-image.c
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-09-23 11:16:50 +0100
committerRichard Hughes <richard@hughsie.com>2015-09-23 11:18:53 +0100
commit09a4ba22a7d5766efcb8eeb674478d69c2e4ba64 (patch)
tree9dd868b14c15fa66d119925e5cf251f05eec495f /libappstream-glib/as-image.c
parent9ea495176266e92af1710df1ead2d34f77f4b67d (diff)
downloadappstream-glib-09a4ba22a7d5766efcb8eeb674478d69c2e4ba64.tar.gz
Use g_set_object() to fix potential crash when adding pixbufs
Diffstat (limited to 'libappstream-glib/as-image.c')
-rw-r--r--libappstream-glib/as-image.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c
index 30828b9..ff09339 100644
--- a/libappstream-glib/as-image.c
+++ b/libappstream-glib/as-image.c
@@ -348,18 +348,14 @@ as_image_set_pixbuf (AsImage *image, GdkPixbuf *pixbuf)
guchar *data;
guint len;
- if (priv->pixbuf != NULL)
- g_object_unref (priv->pixbuf);
- if (pixbuf == NULL) {
- priv->pixbuf = NULL;
+ g_set_object (&priv->pixbuf, pixbuf);
+ if (pixbuf == NULL)
return;
- }
if (priv->md5 == NULL) {
data = gdk_pixbuf_get_pixels_with_length (pixbuf, &len);
priv->md5 = g_compute_checksum_for_data (G_CHECKSUM_MD5,
data, len);
}
- priv->pixbuf = g_object_ref (pixbuf);
priv->width = gdk_pixbuf_get_width (pixbuf);
priv->height = gdk_pixbuf_get_height (pixbuf);
}