[nautilus] files-view: Fix double-free of file list in scripts menu



commit b49246dae890acd376bee585e54cbf73218c33dd
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Jan 9 00:37:54 2016 +0100

    files-view: Fix double-free of file list in scripts menu
    
    When building the scripts menu, update_directory_in_scripts_menu()
    gets the list of files in the script directory, filters out hidden
    files and sorts the filtered list by display name. Unlike the filtering
    step, which returns a new list with ref'ed files, sorting may change
    the start of the list, but not the list's actual content. As a result,
    the nautilus_file_list_free() call added in commit 864c815479a25 tries
    to free already freed memory (i.e. disposed files), resulting in a
    crash when any scripts are found.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=760338

 src/nautilus-files-view.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index b486fb3..6fa737d 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -4804,11 +4804,11 @@ update_directory_in_scripts_menu (NautilusFilesView *view,
         nautilus_file_list_free (file_list);
         menu = g_menu_new ();
 
-        file_list = nautilus_file_list_sort_by_display_name (filtered);
+        filtered = nautilus_file_list_sort_by_display_name (filtered);
 
         num = 0;
         any_scripts = FALSE;
-        for (node = file_list; num < TEMPLATE_LIMIT && node != NULL; node = node->next, num++) {
+        for (node = filtered; num < TEMPLATE_LIMIT && node != NULL; node = node->next, num++) {
                 file = node->data;
                 if (nautilus_file_is_directory (file)) {
                         uri = nautilus_file_get_uri (file);
@@ -4838,7 +4838,6 @@ update_directory_in_scripts_menu (NautilusFilesView *view,
                 }
         }
 
-        nautilus_file_list_free (file_list);
         nautilus_file_list_free (filtered);
 
         if (!any_scripts) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]