Merge lp:~ted/libdbusmenu/about-to-show-null-cb-protect into lp:libdbusmenu/0.6

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 403
Merged at revision: 402
Proposed branch: lp:~ted/libdbusmenu/about-to-show-null-cb-protect
Merge into: lp:libdbusmenu/0.6
Diff against target: 57 lines (+13/-2)
1 file modified
libdbusmenu-glib/client.c (+13/-2)
To merge this branch: bzr merge lp:~ted/libdbusmenu/about-to-show-null-cb-protect
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+100907@code.launchpad.net

Description of the change

Fixing the about-to-show callback to better handle having a NULL callback, and thus NULL data. Putting some protections in as well so we'll get better errors from it if we make this mistake again.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

Looks like this fixes the crash I was seeing yesterday.

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 2012-04-04 04:23:00 +0000
3+++ libdbusmenu-glib/client.c 2012-04-05 04:10:26 +0000
4@@ -1834,6 +1834,8 @@
5 static void
6 about_to_show_finish (about_to_show_t * data, gboolean need_update)
7 {
8+ g_return_if_fail(data != NULL);
9+
10 /* If we need to update, do that first. */
11 if (need_update) {
12 update_layout(data->client);
13@@ -1938,6 +1940,8 @@
14 GQueue * showers = priv->about_to_show_to_go;
15 priv->about_to_show_to_go = NULL;
16
17+ g_return_val_if_fail(showers != NULL, FALSE);
18+
19 /* Figure out if we've got any callbacks */
20 gboolean got_callbacks = FALSE;
21 g_queue_foreach(showers, about_to_show_idle_callbacks, &got_callbacks);
22@@ -1995,7 +1999,10 @@
23 g_variant_unref(params);
24 }
25
26- about_to_show_finish(data, need_update);
27+ if (data != NULL) {
28+ about_to_show_finish(data, need_update);
29+ }
30+
31 return;
32 }
33
34@@ -2028,11 +2035,15 @@
35 priv->about_to_show_idle = g_idle_add(about_to_show_idle, client);
36 }
37 } else {
38+ GAsyncReadyCallback dbuscb = NULL;
39+
40 /* If there's no callback we don't need this data, let's
41 clean it up in a consistent way */
42 if (cb == NULL) {
43 about_to_show_finish(data, FALSE);
44 data = NULL;
45+ } else {
46+ dbuscb = about_to_show_cb;
47 }
48
49 g_dbus_proxy_call(priv->menuproxy,
50@@ -2041,7 +2052,7 @@
51 G_DBUS_CALL_FLAGS_NONE,
52 -1, /* timeout */
53 NULL, /* cancellable */
54- about_to_show_cb,
55+ dbuscb,
56 data);
57 }
58

Subscribers

People subscribed via source and target branches

to all changes: