Merge lp:~rye/ubuntuone-client/no-shared-cb-crash-stable-1-4 into lp:ubuntuone-client

Proposed by Roman Yepishev
Status: Superseded
Proposed branch: lp:~rye/ubuntuone-client/no-shared-cb-crash-stable-1-4
Merge into: lp:ubuntuone-client
Diff against target: 147 lines (+24/-22)
1 file modified
nautilus/ubuntuone-nautilus.c (+24/-22)
To merge this branch: bzr merge lp:~rye/ubuntuone-client/no-shared-cb-crash-stable-1-4
Reviewer Review Type Date Requested Status
dobey (community) Needs Resubmitting
Alejandro J. Cura (community) Approve
Rodrigo Moya (community) Approve
Review via email: mp+36273@code.launchpad.net

Commit message

Reuse shared structure to avoid crashes due to referencing already released memory.

Description of the change

This branch fixes the crashes happening when people click Ubuntu One items in nautilus.
As tested by lp:~rye/+junk/nautilus-bogus-extension there is an extra call to menu entry generation code before activation handler. Since we allocate a new CBData structure every time this routine is called this should lead to a crash when g_free()d memory is referenced.

I agree that this is not an optimal way but it fixes the issue we've been having for quite a long time.

To post a comment you must log in.
Revision history for this message
Rodrigo Moya (rodrigo-moya) :
review: Approve
Revision history for this message
Alejandro J. Cura (alecu) :
review: Approve
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Ugh, this branch has been merged to trunk, where it wasn't supposed to. It should go to stable-1-4. Rodney, can you revert it from trunk? And Roman, it needs to be proposed for stable-1-4

Revision history for this message
dobey (dobey) wrote :

Submitted to wrong branch. Reverted and marking this rejected.

review: Needs Resubmitting

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nautilus/ubuntuone-nautilus.c'
2--- nautilus/ubuntuone-nautilus.c 2010-09-14 14:20:39 +0000
3+++ nautilus/ubuntuone-nautilus.c 2010-09-22 10:11:07 +0000
4@@ -378,21 +378,24 @@
5 iface->get_widget = ubuntuone_nautilus_get_location_widget;
6 }
7
8-static void __cb_data_free (struct _CBData * data) {
9+static void __cb_data_free (struct _CBData * data, gboolean destroy) {
10 if (!data)
11 return;
12
13 data->uon = NULL;
14 data->parent = NULL;
15+ data->make_public = FALSE;
16
17 if (data->path) {
18 g_free (data->path);
19 data->path = NULL;
20 }
21
22- g_free (data);
23+ if (destroy) {
24+ g_free (data);
25+ data = NULL;
26+ }
27
28- data = NULL;
29 }
30
31 /* Menu callbacks */
32@@ -522,7 +525,6 @@
33 gchar * homedir_path;
34 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;
35 gboolean is_inhome, is_dir, is_regular;
36- struct _CBData * cb_data;
37
38 uon = UBUNTUONE_NAUTILUS (provider);
39
40@@ -565,15 +567,15 @@
41 is_dir = nautilus_file_info_is_directory (file);
42 is_regular = nautilus_file_info_get_file_type (file) == G_FILE_TYPE_REGULAR;
43
44+ /* Create new structure only if it does not already exist */
45 if (uon->cb_data)
46- __cb_data_free (uon->cb_data);
47-
48- cb_data = g_new0 (struct _CBData, 1);
49- cb_data->uon = uon;
50- cb_data->parent = window;
51- cb_data->path = g_strdup (path);
52-
53- uon->cb_data = cb_data;
54+ __cb_data_free (uon->cb_data, FALSE);
55+ else
56+ uon->cb_data = g_new0 (struct _CBData, 1);
57+
58+ uon->cb_data->uon = uon;
59+ uon->cb_data->parent = window;
60+ uon->cb_data->path = g_strdup (path);
61
62 root_item = nautilus_menu_item_new ("ubuntuone",
63 _("_Ubuntu One"),
64@@ -599,7 +601,7 @@
65
66 g_signal_connect (item, "activate",
67 G_CALLBACK (ubuntuone_nautilus_share_folder),
68- cb_data);
69+ uon->cb_data);
70 } else {
71 /* the different tooltips will probably do us no good */
72 if (is_root) {
73@@ -636,7 +638,7 @@
74
75 g_signal_connect (item, "activate",
76 G_CALLBACK (ubuntuone_nautilus_unshare_folder),
77- cb_data);
78+ uon->cb_data);
79 nautilus_menu_append_item (submenu, item);
80 }
81
82@@ -667,7 +669,7 @@
83
84 g_signal_connect (item, "activate",
85 G_CALLBACK (ubuntuone_nautilus_unsubscribe_folder),
86- cb_data);
87+ uon->cb_data);
88 }
89 } else {
90 /* unmanaged */
91@@ -679,7 +681,7 @@
92
93 g_signal_connect (item, "activate",
94 G_CALLBACK (ubuntuone_nautilus_subscribe_folder),
95- cb_data);
96+ uon->cb_data);
97 }
98 } else {
99 if (is_dir) {
100@@ -721,7 +723,7 @@
101
102 g_signal_connect (urlitem, "activate",
103 G_CALLBACK (ubuntuone_nautilus_copy_public_url),
104- cb_data);
105+ uon->cb_data);
106 item = nautilus_menu_item_new ("ubuntuone-unpublish",
107 _("Stop _Publishing"),
108 _("No longer share this file with everyone via Ubuntu One."),
109@@ -729,17 +731,17 @@
110 if (is_pending)
111 g_object_set (item, "sensitive", FALSE, NULL);
112
113- cb_data->make_public = FALSE;
114+ uon->cb_data->make_public = FALSE;
115 } else {
116 item = nautilus_menu_item_new ("ubuntuone-publish",
117 _("_Publish"),
118 _("Make this file available to anyone via Ubuntu One."),
119 "ubuntuone");
120- cb_data->make_public = TRUE;
121+ uon->cb_data->make_public = TRUE;
122 }
123 g_signal_connect (item, "activate",
124 G_CALLBACK (ubuntuone_nautilus_toggle_publicity),
125- cb_data);
126+ uon->cb_data);
127 }
128 if (!urlitem) {
129 urlitem = nautilus_menu_item_new ("ubuntuone-geturl",
130@@ -778,7 +780,7 @@
131 }
132 g_signal_connect (item, "activate",
133 G_CALLBACK (toggle_location),
134- cb_data);
135+ uon->cb_data);
136 nautilus_menu_append_item (submenu, item);
137 }
138
139@@ -876,7 +878,7 @@
140 static void ubuntuone_nautilus_finalize(GObject * object) {
141 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS(object);
142
143- __cb_data_free (uon->cb_data);
144+ __cb_data_free (uon->cb_data, TRUE);
145
146 if (uon->syncdaemon)
147 g_object_unref (uon->syncdaemon);

Subscribers

People subscribed via source and target branches