Merge lp:~chrisccoulson/libdbusmenu/lp1104136 into lp:libdbusmenu/13.04

Proposed by Chris Coulson
Status: Merged
Approved by: Ted Gould
Approved revision: 440
Merged at revision: 440
Proposed branch: lp:~chrisccoulson/libdbusmenu/lp1104136
Merge into: lp:libdbusmenu/13.04
Diff against target: 88 lines (+14/-5)
2 files modified
libdbusmenu-glib/menuitem.c (+3/-1)
libdbusmenu-glib/server.c (+11/-4)
To merge this branch: bzr merge lp:~chrisccoulson/libdbusmenu/lp1104136
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+144733@code.launchpad.net

Description of the change

Fix multiple leaks due to improper use of g_variant_parse() (fixes bug 1104136)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Hate GVariants.... Can't believe this isn't a floating reference.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-glib/menuitem.c'
2--- libdbusmenu-glib/menuitem.c 2012-12-17 21:59:01 +0000
3+++ libdbusmenu-glib/menuitem.c 2013-01-24 15:58:21 +0000
4@@ -1656,7 +1656,9 @@
5 if (props != NULL) {
6 g_variant_builder_add_value(&tupleb, props);
7 } else {
8- g_variant_builder_add_value(&tupleb, g_variant_parse(G_VARIANT_TYPE("a{sv}"), "[ ]", NULL, NULL, NULL));
9+ GVariant *empty_props = g_variant_parse(G_VARIANT_TYPE("a{sv}"), "[ ]", NULL, NULL, NULL);
10+ g_variant_builder_add_value(&tupleb, empty_props);
11+ g_variant_unref(empty_props);
12 }
13
14 /* Pillage the children */
15
16=== modified file 'libdbusmenu-glib/server.c'
17--- libdbusmenu-glib/server.c 2013-01-22 16:25:12 +0000
18+++ libdbusmenu-glib/server.c 2013-01-24 15:58:21 +0000
19@@ -1070,8 +1070,6 @@
20 g_error_free(error);
21 megadata[0] = NULL;
22 error_nosend = TRUE;
23- } else {
24- g_variant_ref_sink(megadata[0]);
25 }
26 }
27
28@@ -1088,8 +1086,6 @@
29 g_error_free(error);
30 megadata[1] = NULL;
31 error_nosend = TRUE;
32- } else {
33- g_variant_ref_sink(megadata[1]);
34 }
35 }
36
37@@ -1331,6 +1327,9 @@
38
39 if (mi != NULL) {
40 items = dbusmenu_menuitem_build_variant(mi, props, recurse);
41+ if (items) {
42+ g_variant_ref_sink(items);
43+ }
44 }
45 }
46 g_free(props);
47@@ -1360,6 +1359,8 @@
48 g_variant_builder_add_value(&tuplebuilder, g_variant_new_uint32(revision));
49 g_variant_builder_add_value(&tuplebuilder, items);
50
51+ g_variant_unref(items);
52+
53 GVariant * retval = g_variant_builder_end(&tuplebuilder);
54 // g_debug("Sending layout type: %s", g_variant_get_type_string(retval));
55 g_dbus_method_invocation_return_value(invocation,
56@@ -1504,6 +1505,9 @@
57 g_variant_builder_init(&wbuilder, G_VARIANT_TYPE_TUPLE);
58 g_variant_builder_add(&wbuilder, "i", id);
59 GVariant * props = dbusmenu_menuitem_properties_variant(mi, NULL);
60+ if (props != NULL) {
61+ g_variant_ref(props);
62+ }
63
64 if (props == NULL) {
65 GError * error = NULL;
66@@ -1516,6 +1520,7 @@
67 }
68
69 g_variant_builder_add_value(&wbuilder, props);
70+ g_variant_unref(props);
71 GVariant * mi_data = g_variant_builder_end(&wbuilder);
72
73 g_variant_builder_add_value(&builder, mi_data);
74@@ -1613,6 +1618,7 @@
75
76 GVariant * end = g_variant_builder_end(&builder);
77 ret = g_variant_new_tuple(&end, 1);
78+ g_variant_ref_sink(ret);
79 } else {
80 GError * error = NULL;
81 ret = g_variant_parse(G_VARIANT_TYPE("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, &error);
82@@ -1624,6 +1630,7 @@
83 }
84
85 g_dbus_method_invocation_return_value(invocation, ret);
86+ g_variant_unref(ret);
87 return;
88 }
89

Subscribers

People subscribed via source and target branches

to all changes: