menu_removed_cb: fix 'name' leak
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 11 Sep 2013 14:27:04 +0000 (16:27 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 25 Sep 2013 13:21:50 +0000 (15:21 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=707885

src/empathy-roster-window.c

index 9dd7a4e..667267f 100644 (file)
@@ -1360,16 +1360,22 @@ roster_window_favorite_chatroom_menu_removed_cb (
 
   for (i = 0; i < n; i++)
     {
-      const gchar *name;
+      gchar *name;
 
-      if (g_menu_model_get_item_attribute (
-            G_MENU_MODEL (self->priv->rooms_section), i, "room-name",
-            "s", &name)
-          && !tp_strdiff (name, empathy_chatroom_get_name (chatroom)))
+      if (!g_menu_model_get_item_attribute (
+            G_MENU_MODEL (self->priv->rooms_section), i,
+            "room-name", "s", &name))
+        continue;
+
+      if (tp_strdiff (name, empathy_chatroom_get_name (chatroom)))
         {
-          g_menu_remove (self->priv->rooms_section, i);
-          break;
+          g_free (name);
+          continue;
         }
+
+      g_menu_remove (self->priv->rooms_section, i);
+      g_free (name);
+      break;
     }
 
   chatrooms = empathy_chatroom_manager_get_chatrooms (