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
=== modified file 'nautilus/ubuntuone-nautilus.c'
--- nautilus/ubuntuone-nautilus.c 2010-09-14 14:20:39 +0000
+++ nautilus/ubuntuone-nautilus.c 2010-09-22 10:11:07 +0000
@@ -378,21 +378,24 @@
378 iface->get_widget = ubuntuone_nautilus_get_location_widget;378 iface->get_widget = ubuntuone_nautilus_get_location_widget;
379}379}
380380
381static void __cb_data_free (struct _CBData * data) {381static void __cb_data_free (struct _CBData * data, gboolean destroy) {
382 if (!data)382 if (!data)
383 return;383 return;
384384
385 data->uon = NULL;385 data->uon = NULL;
386 data->parent = NULL;386 data->parent = NULL;
387 data->make_public = FALSE;
387388
388 if (data->path) {389 if (data->path) {
389 g_free (data->path);390 g_free (data->path);
390 data->path = NULL;391 data->path = NULL;
391 }392 }
392393
393 g_free (data);394 if (destroy) {
395 g_free (data);
396 data = NULL;
397 }
394398
395 data = NULL;
396}399}
397400
398/* Menu callbacks */401/* Menu callbacks */
@@ -522,7 +525,6 @@
522 gchar * homedir_path;525 gchar * homedir_path;
523 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;526 gboolean is_managed, is_root, is_udf, is_public, is_shared, is_pending;
524 gboolean is_inhome, is_dir, is_regular;527 gboolean is_inhome, is_dir, is_regular;
525 struct _CBData * cb_data;
526528
527 uon = UBUNTUONE_NAUTILUS (provider);529 uon = UBUNTUONE_NAUTILUS (provider);
528530
@@ -565,15 +567,15 @@
565 is_dir = nautilus_file_info_is_directory (file);567 is_dir = nautilus_file_info_is_directory (file);
566 is_regular = nautilus_file_info_get_file_type (file) == G_FILE_TYPE_REGULAR;568 is_regular = nautilus_file_info_get_file_type (file) == G_FILE_TYPE_REGULAR;
567569
570 /* Create new structure only if it does not already exist */
568 if (uon->cb_data)571 if (uon->cb_data)
569 __cb_data_free (uon->cb_data);572 __cb_data_free (uon->cb_data, FALSE);
570573 else
571 cb_data = g_new0 (struct _CBData, 1);574 uon->cb_data = g_new0 (struct _CBData, 1);
572 cb_data->uon = uon;575
573 cb_data->parent = window;576 uon->cb_data->uon = uon;
574 cb_data->path = g_strdup (path);577 uon->cb_data->parent = window;
575578 uon->cb_data->path = g_strdup (path);
576 uon->cb_data = cb_data;
577579
578 root_item = nautilus_menu_item_new ("ubuntuone",580 root_item = nautilus_menu_item_new ("ubuntuone",
579 _("_Ubuntu One"),581 _("_Ubuntu One"),
@@ -599,7 +601,7 @@
599601
600 g_signal_connect (item, "activate",602 g_signal_connect (item, "activate",
601 G_CALLBACK (ubuntuone_nautilus_share_folder),603 G_CALLBACK (ubuntuone_nautilus_share_folder),
602 cb_data);604 uon->cb_data);
603 } else {605 } else {
604 /* the different tooltips will probably do us no good */606 /* the different tooltips will probably do us no good */
605 if (is_root) {607 if (is_root) {
@@ -636,7 +638,7 @@
636638
637 g_signal_connect (item, "activate",639 g_signal_connect (item, "activate",
638 G_CALLBACK (ubuntuone_nautilus_unshare_folder),640 G_CALLBACK (ubuntuone_nautilus_unshare_folder),
639 cb_data);641 uon->cb_data);
640 nautilus_menu_append_item (submenu, item);642 nautilus_menu_append_item (submenu, item);
641 }643 }
642644
@@ -667,7 +669,7 @@
667669
668 g_signal_connect (item, "activate",670 g_signal_connect (item, "activate",
669 G_CALLBACK (ubuntuone_nautilus_unsubscribe_folder),671 G_CALLBACK (ubuntuone_nautilus_unsubscribe_folder),
670 cb_data);672 uon->cb_data);
671 }673 }
672 } else {674 } else {
673 /* unmanaged */675 /* unmanaged */
@@ -679,7 +681,7 @@
679681
680 g_signal_connect (item, "activate",682 g_signal_connect (item, "activate",
681 G_CALLBACK (ubuntuone_nautilus_subscribe_folder),683 G_CALLBACK (ubuntuone_nautilus_subscribe_folder),
682 cb_data);684 uon->cb_data);
683 }685 }
684 } else {686 } else {
685 if (is_dir) {687 if (is_dir) {
@@ -721,7 +723,7 @@
721723
722 g_signal_connect (urlitem, "activate",724 g_signal_connect (urlitem, "activate",
723 G_CALLBACK (ubuntuone_nautilus_copy_public_url),725 G_CALLBACK (ubuntuone_nautilus_copy_public_url),
724 cb_data);726 uon->cb_data);
725 item = nautilus_menu_item_new ("ubuntuone-unpublish",727 item = nautilus_menu_item_new ("ubuntuone-unpublish",
726 _("Stop _Publishing"),728 _("Stop _Publishing"),
727 _("No longer share this file with everyone via Ubuntu One."),729 _("No longer share this file with everyone via Ubuntu One."),
@@ -729,17 +731,17 @@
729 if (is_pending)731 if (is_pending)
730 g_object_set (item, "sensitive", FALSE, NULL);732 g_object_set (item, "sensitive", FALSE, NULL);
731733
732 cb_data->make_public = FALSE;734 uon->cb_data->make_public = FALSE;
733 } else {735 } else {
734 item = nautilus_menu_item_new ("ubuntuone-publish",736 item = nautilus_menu_item_new ("ubuntuone-publish",
735 _("_Publish"),737 _("_Publish"),
736 _("Make this file available to anyone via Ubuntu One."),738 _("Make this file available to anyone via Ubuntu One."),
737 "ubuntuone");739 "ubuntuone");
738 cb_data->make_public = TRUE;740 uon->cb_data->make_public = TRUE;
739 }741 }
740 g_signal_connect (item, "activate",742 g_signal_connect (item, "activate",
741 G_CALLBACK (ubuntuone_nautilus_toggle_publicity),743 G_CALLBACK (ubuntuone_nautilus_toggle_publicity),
742 cb_data);744 uon->cb_data);
743 }745 }
744 if (!urlitem) {746 if (!urlitem) {
745 urlitem = nautilus_menu_item_new ("ubuntuone-geturl",747 urlitem = nautilus_menu_item_new ("ubuntuone-geturl",
@@ -778,7 +780,7 @@
778 }780 }
779 g_signal_connect (item, "activate",781 g_signal_connect (item, "activate",
780 G_CALLBACK (toggle_location),782 G_CALLBACK (toggle_location),
781 cb_data);783 uon->cb_data);
782 nautilus_menu_append_item (submenu, item);784 nautilus_menu_append_item (submenu, item);
783 }785 }
784786
@@ -876,7 +878,7 @@
876static void ubuntuone_nautilus_finalize(GObject * object) {878static void ubuntuone_nautilus_finalize(GObject * object) {
877 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS(object);879 UbuntuOneNautilus * uon = UBUNTUONE_NAUTILUS(object);
878880
879 __cb_data_free (uon->cb_data);881 __cb_data_free (uon->cb_data, TRUE);
880882
881 if (uon->syncdaemon)883 if (uon->syncdaemon)
882 g_object_unref (uon->syncdaemon);884 g_object_unref (uon->syncdaemon);

Subscribers

People subscribed via source and target branches