glib r6666 - trunk/gio



Author: alexl
Date: Tue Mar 11 00:14:11 2008
New Revision: 6666
URL: http://svn.gnome.org/viewvc/glib?rev=6666&view=rev

Log:
2008-03-11  Alexander Larsson  <alexl redhat com>

        * gthemedicon.c:
	Fix crashes in new constructor and properties code



Modified:
   trunk/gio/ChangeLog
   trunk/gio/gthemedicon.c

Modified: trunk/gio/gthemedicon.c
==============================================================================
--- trunk/gio/gthemedicon.c	(original)
+++ trunk/gio/gthemedicon.c	Tue Mar 11 00:14:11 2008
@@ -97,21 +97,35 @@
                             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 @@
    *
    * 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 @@
       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];



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]