diff options
author | Matthias Clasen <mclasen@redhat.com> | 2011-12-14 21:05:38 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2011-12-14 21:05:38 -0500 |
commit | a6eda97d8e8440ea5b04c081d444916dc51ad220 (patch) | |
tree | 8647b44d4ac91471b59b1176785ae0a3d7558701 /gio | |
parent | e129deb0170c8a18e662c53db799f2ba16ebf26f (diff) | |
download | glib-a6eda97d8e8440ea5b04c081d444916dc51ad220.tar.gz glib-a6eda97d8e8440ea5b04c081d444916dc51ad220.tar.bz2 glib-a6eda97d8e8440ea5b04c081d444916dc51ad220.zip |
menu markup: tolerate not having a hash table of objects
Various places in the code were assuming that the hash table was always
available. Fix this, and also avoid leaking strings now that the hash
table may be NULL.
Based on a patch by Simon McVittie, bug 666167
Diffstat (limited to 'gio')
-rw-r--r-- | gio/gmenumarkup.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gio/gmenumarkup.c b/gio/gmenumarkup.c index bde3989f4..c0df3b62d 100644 --- a/gio/gmenumarkup.c +++ b/gio/gmenumarkup.c @@ -138,19 +138,20 @@ g_menu_markup_start_element (GMarkupParseContext *context, #define STRING G_MARKUP_COLLECT_STRING #define NO_ATTRS() COLLECT (G_MARKUP_COLLECT_INVALID, NULL) - if (!(state->frame.menu || state->frame.menu || state->string)) + if (!(state->frame.menu || state->frame.item || state->string)) { /* Can only have <menu> here. */ if (g_str_equal (element_name, "menu")) { gchar *id; - if (COLLECT (STRDUP, "id", &id)) + if (COLLECT (STRING, "id", &id)) { GMenu *menu; menu = g_menu_new (); - g_hash_table_insert (state->objects, id, menu); + if (state->objects) + g_hash_table_insert (state->objects, g_strdup (id), menu); g_menu_markup_push_frame (state, menu, NULL); } @@ -244,7 +245,7 @@ g_menu_markup_start_element (GMarkupParseContext *context, g_menu_item_set_link (state->frame.item, name, G_MENU_MODEL (menu)); g_menu_markup_push_frame (state, menu, NULL); - if (id != NULL) + if (id != NULL && state->objects) g_hash_table_insert (state->objects, g_strdup (id), g_object_ref (menu)); } |