ayatana-commits team mailing list archive
-
ayatana-commits team
-
Mailing list archive
-
Message #02857
[Branch ~dbusmenu-team/dbusmenu/trunk] Rev 194: Fix some memory leaks, we hate those!
Merge authors:
Ted Gould (ted)
Related merge proposals:
https://code.launchpad.net/~ted/dbusmenu/mem-leaks/+merge/47083
proposed by: Ted Gould (ted)
review: Approve - Mikkel Kamstrup Erlandsen (kamstrup)
------------------------------------------------------------
revno: 194 [merge]
committer: Ted Gould <ted@xxxxxxxx>
branch nick: trunk
timestamp: Wed 2011-01-26 17:12:22 -0600
message:
Fix some memory leaks, we hate those!
modified:
libdbusmenu-glib/client.c
libdbusmenu-glib/menuitem.c
--
lp:dbusmenu
https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk
Your team ayatana-commits is subscribed to branch lp:dbusmenu.
To unsubscribe from this branch go to https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk/+edit-subscription
=== modified file 'libdbusmenu-glib/client.c'
--- libdbusmenu-glib/client.c 2011-01-25 18:18:05 +0000
+++ libdbusmenu-glib/client.c 2011-01-26 23:12:22 +0000
@@ -517,6 +517,7 @@
listener->callback(NULL, error, listener->user_data);
}
g_array_free(listeners, TRUE);
+ g_error_free(error);
return;
}
@@ -1140,7 +1141,6 @@
if (error != NULL) {
g_warning("Error getting properties on a new menuitem: %s", error->message);
g_object_unref(propdata->item);
- g_free(data);
return;
}
@@ -1277,6 +1277,8 @@
g_warning("Unable to send about_to_show: %s", error->message);
/* Note: we're just ensuring only the callback gets called */
need_update = FALSE;
+ g_error_free(error);
+ error = NULL;
} else {
g_variant_get(params, "(b)", &need_update);
g_variant_unref(params);
@@ -1553,6 +1555,7 @@
if (error != NULL) {
g_warning("Getting layout failed: %s", error->message);
+ g_error_free(error);
return;
}
=== modified file 'libdbusmenu-glib/menuitem.c'
--- libdbusmenu-glib/menuitem.c 2011-01-07 05:25:02 +0000
+++ libdbusmenu-glib/menuitem.c 2011-01-21 19:27:26 +0000
@@ -1204,11 +1204,17 @@
return g_hash_table_get_keys(priv->properties);
}
+/* Copy the keys and make references to the variants that are
+ in the new table. They'll be free'd and unref'd when the
+ Hashtable gets destroyed. */
static void
copy_helper (gpointer in_key, gpointer in_value, gpointer in_data)
{
GHashTable * table = (GHashTable *)in_data;
- g_hash_table_insert(table, in_key, in_value);
+ gchar * key = (gchar *)in_key;
+ GVariant * value = (GVariant *)in_value;
+ g_variant_ref(value);
+ g_hash_table_insert(table, g_strdup(key), value);
return;
}
@@ -1229,7 +1235,7 @@
GHashTable *
dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi)
{
- GHashTable * ret = g_hash_table_new(g_str_hash, g_str_equal);
+ GHashTable * ret = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_variant_unref);
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), ret);