[glib] Don't crash if set_app_info is called before adding metadata



commit dbad8304ff123f7fe242bdd8a8cfcb7eef8afce6
Author: William Jon McCann <jmccann redhat com>
Date:   Fri Aug 24 13:32:25 2012 -0400

    Don't crash if set_app_info is called before adding metadata
    
    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 |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c
index edf196b..f8c2756 100644
--- a/glib/gbookmarkfile.c
+++ b/glib/gbookmarkfile.c
@@ -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)
     {



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