Don't crash if set_app_info is called before adding metadata
authorWilliam Jon McCann <jmccann@redhat.com>
Fri, 24 Aug 2012 17:32:25 +0000 (13:32 -0400)
committerWilliam Jon McCann <jmccann@redhat.com>
Fri, 24 Aug 2012 17:36:26 +0000 (13:36 -0400)
set_mime_type, set_is_private, add_group, set_groups, set_icon, etc
all added metadata before using it. If set_app_info was called before
any of those it would crash when trying to access the metadata.

glib/gbookmarkfile.c

index edf196b..f8c2756 100644 (file)
@@ -3234,6 +3234,9 @@ g_bookmark_file_set_app_info (GBookmarkFile  *bookmark,
        }
     }
   
+  if (!item->metadata)
+    item->metadata = bookmark_metadata_new ();
+
   ai = bookmark_item_lookup_app_info (item, name);
   if (!ai)
     {