Merge lp:~ted/libdbusmenu/mem-leaks into lp:libdbusmenu/0.5

Proposed by Ted Gould
Status: Merged
Merged at revision: 194
Proposed branch: lp:~ted/libdbusmenu/mem-leaks
Merge into: lp:libdbusmenu/0.5
Diff against target: 67 lines (+12/-3)
2 files modified
libdbusmenu-glib/client.c (+4/-1)
libdbusmenu-glib/menuitem.c (+8/-2)
To merge this branch: bzr merge lp:~ted/libdbusmenu/mem-leaks
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+47083@code.launchpad.net

Description of the change

Taking the heart of a patch attached to bug 690668 by hyperair. It didn't apply, but I think I found parts that still were issues by using it as a guide.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

 review approve

Looks good to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-glib/client.c'
2--- libdbusmenu-glib/client.c 2011-01-19 14:55:37 +0000
3+++ libdbusmenu-glib/client.c 2011-01-21 19:38:10 +0000
4@@ -517,6 +517,7 @@
5 listener->callback(NULL, error, listener->user_data);
6 }
7 g_array_free(listeners, TRUE);
8+ g_error_free(error);
9 return;
10 }
11
12@@ -1140,7 +1141,6 @@
13 if (error != NULL) {
14 g_warning("Error getting properties on a new menuitem: %s", error->message);
15 g_object_unref(propdata->item);
16- g_free(data);
17 return;
18 }
19
20@@ -1277,6 +1277,8 @@
21 g_warning("Unable to send about_to_show: %s", error->message);
22 /* Note: we're just ensuring only the callback gets called */
23 need_update = FALSE;
24+ g_error_free(error);
25+ error = NULL;
26 } else {
27 g_variant_get(params, "(b)", &need_update);
28 g_variant_unref(params);
29@@ -1553,6 +1555,7 @@
30
31 if (error != NULL) {
32 g_warning("Getting layout failed: %s", error->message);
33+ g_error_free(error);
34 return;
35 }
36
37
38=== modified file 'libdbusmenu-glib/menuitem.c'
39--- libdbusmenu-glib/menuitem.c 2011-01-07 05:25:02 +0000
40+++ libdbusmenu-glib/menuitem.c 2011-01-21 19:38:10 +0000
41@@ -1204,11 +1204,17 @@
42 return g_hash_table_get_keys(priv->properties);
43 }
44
45+/* Copy the keys and make references to the variants that are
46+ in the new table. They'll be free'd and unref'd when the
47+ Hashtable gets destroyed. */
48 static void
49 copy_helper (gpointer in_key, gpointer in_value, gpointer in_data)
50 {
51 GHashTable * table = (GHashTable *)in_data;
52- g_hash_table_insert(table, in_key, in_value);
53+ gchar * key = (gchar *)in_key;
54+ GVariant * value = (GVariant *)in_value;
55+ g_variant_ref(value);
56+ g_hash_table_insert(table, g_strdup(key), value);
57 return;
58 }
59
60@@ -1229,7 +1235,7 @@
61 GHashTable *
62 dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi)
63 {
64- GHashTable * ret = g_hash_table_new(g_str_hash, g_str_equal);
65+ GHashTable * ret = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_variant_unref);
66
67 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), ret);
68

Subscribers

People subscribed via source and target branches