diff -Nru indicator-appmenu-13.01.0+14.04.20140318/debian/changelog indicator-appmenu-13.01.0+14.04.20140320/debian/changelog --- indicator-appmenu-13.01.0+14.04.20140318/debian/changelog 2014-03-20 09:09:13.000000000 +0000 +++ indicator-appmenu-13.01.0+14.04.20140320/debian/changelog 2014-03-20 09:09:13.000000000 +0000 @@ -1,3 +1,10 @@ +indicator-appmenu (13.01.0+14.04.20140320-0ubuntu1) trusty; urgency=low + + [ Charles Kerr ] + * Don't dereference a NULL WindowMenu pointer. (LP: #1294545) + + -- Ubuntu daily release Thu, 20 Mar 2014 09:03:45 +0000 + indicator-appmenu (13.01.0+14.04.20140318-0ubuntu1) trusty; urgency=low [ Charles Kerr ] diff -Nru indicator-appmenu-13.01.0+14.04.20140318/src/indicator-appmenu.c indicator-appmenu-13.01.0+14.04.20140320/src/indicator-appmenu.c --- indicator-appmenu-13.01.0+14.04.20140318/src/indicator-appmenu.c 2014-03-18 09:52:14.000000000 +0000 +++ indicator-appmenu-13.01.0+14.04.20140320/src/indicator-appmenu.c 2014-03-20 09:03:36.000000000 +0000 @@ -195,8 +195,6 @@ static void on_name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data); -static void menus_destroyed (GObject * menus, - gpointer user_data); static GVariant * unregister_window (IndicatorAppmenu * iapp, guint windowid); @@ -1054,18 +1052,15 @@ /* Respond to the menus being destroyed. We need to deregister and make sure we weren't being shown. */ static void -menus_destroyed (GObject * menus, gpointer user_data) +menus_destroyed (IndicatorAppmenu * iapp, guint windowid) { gboolean reload_menus = FALSE; - WindowMenu * wm = WINDOW_MENU(menus); - IndicatorAppmenu * iapp = INDICATOR_APPMENU(user_data); - - guint32 xid = window_menu_get_xid(wm); - g_return_if_fail(xid != 0); + WindowMenu * wm = g_hash_table_lookup(iapp->apps, GUINT_TO_POINTER(windowid)); + g_return_if_fail (wm != NULL); - g_hash_table_steal(iapp->apps, GUINT_TO_POINTER(xid)); + g_hash_table_steal(iapp->apps, GUINT_TO_POINTER(windowid)); - g_debug("Removing menus for %d", xid); + g_debug("Removing menus for %d", windowid); if (iapp->desktop_menu == wm) { iapp->desktop_menu = NULL; @@ -1085,7 +1080,7 @@ switch_default_app(iapp, NULL, NULL); } - return; + g_object_unref(wm); } /* A new window wishes to register it's windows with us */ @@ -1149,19 +1144,7 @@ emit_signal(iapp, "WindowUnregistered", g_variant_new ("(u)", windowid)); - /* Now let's see if we've got a WM object for it then - we need to mark it as destroyed and unreference to - actually destroy it. */ - gpointer wm = g_hash_table_lookup(iapp->apps, GUINT_TO_POINTER(windowid)); - if (wm != NULL) { - GObject * wmo = G_OBJECT(wm); - - /* Using destroyed so that if the menus are shown - they'll be switch and the current window gets - updated as well. */ - menus_destroyed(wmo, iapp); - g_object_unref(wmo); - } + menus_destroyed(iapp, windowid); return NULL; } diff -Nru indicator-appmenu-13.01.0+14.04.20140318/src/window-menu.c indicator-appmenu-13.01.0+14.04.20140320/src/window-menu.c --- indicator-appmenu-13.01.0+14.04.20140318/src/window-menu.c 2014-03-18 09:52:14.000000000 +0000 +++ indicator-appmenu-13.01.0+14.04.20140320/src/window-menu.c 2014-03-20 09:03:36.000000000 +0000 @@ -136,6 +136,8 @@ GList * window_menu_get_entries (WindowMenu * wm) { + g_return_val_if_fail (IS_WINDOW_MENU(wm), NULL); + WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm); if (class->get_entries != NULL) { @@ -148,6 +150,8 @@ guint window_menu_get_location (WindowMenu * wm, IndicatorObjectEntry * entry) { + g_return_val_if_fail (IS_WINDOW_MENU(wm), 0); + WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm); if (class->get_location != NULL) { @@ -160,6 +164,8 @@ guint window_menu_get_xid (WindowMenu * wm) { + g_return_val_if_fail (IS_WINDOW_MENU(wm), 0); + WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm); if (class->get_xid != NULL) { @@ -172,6 +178,8 @@ gboolean window_menu_get_error_state (WindowMenu * wm) { + g_return_val_if_fail (IS_WINDOW_MENU(wm), FALSE); + WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm); if (class->get_error_state != NULL) { @@ -184,6 +192,8 @@ WindowMenuStatus window_menu_get_status (WindowMenu * wm) { + g_return_val_if_fail (IS_WINDOW_MENU(wm), WINDOW_MENU_STATUS_NORMAL); + WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm); if (class->get_status != NULL) { @@ -196,6 +206,8 @@ void window_menu_entry_restore (WindowMenu * wm, IndicatorObjectEntry * entry) { + g_return_if_fail (IS_WINDOW_MENU(wm)); + WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm); if (class->entry_restore != NULL) { @@ -208,6 +220,8 @@ void window_menu_entry_activate (WindowMenu * wm, IndicatorObjectEntry * entry, guint timestamp) { + g_return_if_fail (IS_WINDOW_MENU(wm)); + WindowMenuClass * class = WINDOW_MENU_GET_CLASS(wm); if (class->entry_activate != NULL) {