summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2016-09-16 10:03:15 +0200
committerCarlos Soriano <csoriano@gnome.org>2016-09-20 16:44:35 +0200
commit6053de7d94c961c9e945a2fcd81f915d9f94bcdc (patch)
treec0249ff10393df99e66fe1e4467148a6fa0a905f
parente0284d001624ad33f566121fd7223ef9cf80de61 (diff)
downloadnautilus-6053de7d94c961c9e945a2fcd81f915d9f94bcdc.tar.gz
batch-rename-dialog: don't transfer ownership from caller to called
This is common good practice, otherwise it's not clear who has ownership, making it error prone for dangling pointers (this case) or use after free.
-rw-r--r--src/nautilus-batch-rename-dialog.c7
-rw-r--r--src/nautilus-files-view.c2
2 files changed, 6 insertions, 3 deletions
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index 5a60cddde..a545d2fb5 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -2032,6 +2032,9 @@ nautilus_batch_rename_dialog_finalize (GObject *object)
g_list_free_full (dialog->new_names, string_free);
g_list_free_full (dialog->duplicates, conflict_data_free);
+ nautilus_file_list_free (dialog->selection);
+ nautilus_directory_unref (dialog->directory);
+
G_OBJECT_CLASS (nautilus_batch_rename_dialog_parent_class)->finalize (object);
}
@@ -2100,8 +2103,8 @@ nautilus_batch_rename_dialog_new (GList *selection,
dialog = g_object_new (NAUTILUS_TYPE_BATCH_RENAME_DIALOG, "use-header-bar", TRUE, NULL);
- dialog->selection = selection;
- dialog->directory = directory;
+ dialog->selection = nautilus_file_list_copy (selection);
+ dialog->directory = nautilus_directory_ref (directory);
dialog->window = window;
gtk_window_set_transient_for (GTK_WINDOW (dialog),
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index d8aa3c6c3..11c5175cc 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -5971,7 +5971,7 @@ real_action_rename (NautilusFilesView *view)
cursor);
g_object_unref (cursor);
- dialog = nautilus_batch_rename_dialog_new (nautilus_files_view_get_selection (NAUTILUS_VIEW (view)),
+ dialog = nautilus_batch_rename_dialog_new (selection,
nautilus_files_view_get_model (view),
nautilus_files_view_get_window (view));