Merge lp:~ted/libdbusmenu/lp741726 into lp:libdbusmenu/0.5

Proposed by Ted Gould
Status: Merged
Merged at revision: 283
Proposed branch: lp:~ted/libdbusmenu/lp741726
Merge into: lp:libdbusmenu/0.5
Diff against target: 70 lines (+23/-5)
1 file modified
libdbusmenu-glib/client.c (+23/-5)
To merge this branch: bzr merge lp:~ted/libdbusmenu/lp741726
Reviewer Review Type Date Requested Status
Conor Curran (community) Approve
Review via email: mp+54719@code.launchpad.net

Description of the change

Additional protections on the properties. We're getting something that isn't kosher, let's push it out!

To post a comment you must log in.
Revision history for this message
Conor Curran (cjcurran) :
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-03-23 15:48:52 +0000
3+++ libdbusmenu-glib/client.c 2011-03-24 16:07:13 +0000
4@@ -1333,8 +1333,16 @@
5
6 if (error != NULL) {
7 g_warning("Error getting properties on a menuitem: %s", error->message);
8- g_object_unref(data);
9- return;
10+ goto out;
11+ }
12+
13+ if (properties == NULL) {
14+ goto out;
15+ }
16+
17+ if (!g_variant_is_of_type(properties, G_VARIANT_TYPE("a{sv}"))) {
18+ g_warning("Properties are of type '%s' instead of type '%s'", g_variant_get_type_string(properties), "a{sv}");
19+ goto out;
20 }
21
22 GVariantIter iter;
23@@ -1347,6 +1355,7 @@
24 dbusmenu_menuitem_property_set_variant(item, key, value);
25 }
26
27+out:
28 g_object_unref(data);
29
30 return;
31@@ -1365,12 +1374,16 @@
32 g_warning("Unable to replace properties on %d: %s", dbusmenu_menuitem_get_id(DBUSMENU_MENUITEM(data)), error->message);
33 have_error = TRUE;
34 }
35+
36+ if (properties == NULL) {
37+ have_error = TRUE;
38+ }
39
40 /* Get the list of the current properties */
41 GList * current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data));
42 GList * tmp = NULL;
43
44- if (properties != NULL) {
45+ if (!have_error && g_variant_is_of_type(properties, G_VARIANT_TYPE("a{sv}"))) {
46 GVariantIter iter;
47 g_variant_iter_init(&iter, properties);
48 gchar * name; GVariant * value;
49@@ -1414,8 +1427,12 @@
50
51 if (error != NULL) {
52 g_warning("Error getting properties on a new menuitem: %s", error->message);
53- g_object_unref(propdata->item);
54- return;
55+ goto out;
56+ }
57+
58+ if (properties == NULL) {
59+ g_warning("Not realizing new item as properties for it were unavailable");
60+ goto out;
61 }
62
63 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(propdata->client);
64@@ -1449,6 +1466,7 @@
65 g_signal_emit(G_OBJECT(propdata->client), signals[NEW_MENUITEM], 0, propdata->item, TRUE);
66 }
67
68+out:
69 g_object_unref(propdata->item);
70 g_free(propdata);
71

Subscribers

People subscribed via source and target branches