diff options
author | Ted Gould <ted@gould.cx> | 2011-09-19 23:27:29 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-09-19 23:27:29 -0500 |
commit | 3ea5f5573cc0f0f34591ee12b92d789bf624d784 (patch) | |
tree | 51c647d61a4ce3f6c6d20dee0a4a6d41c1c73bab | |
parent | 4810423912b7f53f716ba5665aba56234461ca6f (diff) | |
parent | 0b5f7ed8fcaee4b32db7a1deed1b65ff77688551 (diff) | |
download | libdbusmenu-3ea5f5573cc0f0f34591ee12b92d789bf624d784.tar.gz libdbusmenu-3ea5f5573cc0f0f34591ee12b92d789bf624d784.tar.bz2 libdbusmenu-3ea5f5573cc0f0f34591ee12b92d789bf624d784.zip |
Protect the parse from segfaults
-rw-r--r-- | libdbusmenu-gtk/parser.c | 3 | ||||
-rw-r--r-- | tests/test-gtk-parser.c | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 3243c81..e988c62 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -283,6 +283,9 @@ toggle_widget_visibility (GtkWidget * widget) static void watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu) { + g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + g_return_if_fail(GTK_IS_MENU_SHELL(menu)); + ParserData *pdata = (ParserData *)g_object_get_data(G_OBJECT(mi), PARSER_DATA); pdata->shell = menu; diff --git a/tests/test-gtk-parser.c b/tests/test-gtk-parser.c index 87b0a7f..afd6194 100644 --- a/tests/test-gtk-parser.c +++ b/tests/test-gtk-parser.c @@ -28,6 +28,8 @@ test_parser_runs (void) { GtkWidget * gmi = gtk_menu_item_new_with_label("Test Item"); g_assert(gmi != NULL); + g_object_ref_sink(gmi); + DbusmenuMenuitem * mi = dbusmenu_gtk_parse_menu_structure(gmi); g_assert(mi != NULL); |