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 864c815479 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
This commit is contained in:
Florian Müllner 2016-01-09 00:37:54 +01:00
parent e3d2316758
commit b49246dae8

View file

@ -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) {