From fd2e57c644ede9cd7d46c0957426be854ae809e8 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Tue, 11 Mar 2008 00:14:11 +0000 Subject: [PATCH] Fix crashes in new constructor and properties code 2008-03-11 Alexander Larsson * gthemedicon.c: Fix crashes in new constructor and properties code svn path=/trunk/; revision=6666 --- gio/ChangeLog | 5 +++++ gio/gthemedicon.c | 22 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index 54e046971..593cab71c 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,8 @@ +2008-03-11 Alexander Larsson + + * gthemedicon.c: + Fix crashes in new constructor and properties code + 2008-03-10 Murray Cumming * gfile.c: Minor spelling correction in documentation: diff --git a/gio/gthemedicon.c b/gio/gthemedicon.c index e642c3e9a..d59f69697 100644 --- a/gio/gthemedicon.c +++ b/gio/gthemedicon.c @@ -97,21 +97,35 @@ g_themed_icon_set_property (GObject *object, GParamSpec *pspec) { GThemedIcon *icon = G_THEMED_ICON (object); + gchar **names; + const gchar *name; switch (prop_id) { case PROP_NAME: + name = g_value_get_string (value); + + if (!name) + break; + if (icon->names) g_strfreev (icon->names); + icon->names = g_new (char *, 2); - icon->names[0] = g_value_dup_string (value); + icon->names[0] = g_strdup (name); icon->names[1] = NULL; break; case PROP_NAMES: + names = g_value_dup_boxed (value); + + if (!names) + break; + if (icon->names) g_strfreev (icon->names); - icon->names = g_value_dup_boxed (value); + + icon->names = names; break; case PROP_USE_DEFAULT_FALLBACKS: @@ -187,7 +201,7 @@ g_themed_icon_class_init (GThemedIconClass *klass) * * The icon name. */ - g_object_class_install_property (gobject_class, PROP_NAMES, + g_object_class_install_property (gobject_class, PROP_NAME, g_param_spec_string ("name", _("name"), _("The name of the icon"), @@ -278,7 +292,7 @@ g_themed_icon_new_from_names (char **iconnames, char **names; int i; - names = g_malloc (len + 1); + names = g_new (char *, len + 1); for (i = 0; i < len; i++) names[i] = iconnames[i];