From d622bad925e7adac5a83ee48181f56d24d20c02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacy=20Kuchci=C5=84ski?= Date: Thu, 8 Sep 2022 23:25:36 +0200 Subject: window-slot: Fix leak Currently, if the new_selection list is NULL, then the check_select_old_location_containing_folder function sets it to a newly allocated list. Since we don't own the new_selection list, let's copy it before passing it to the check_select_old_location_containing_folder function so that it always returns a newly allocated list, which we make the pending_selection point to in order to avoid a leak. --- src/nautilus-window-slot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c index 2efa6cadf..2659916b2 100644 --- a/src/nautilus-window-slot.c +++ b/src/nautilus-window-slot.c @@ -1354,15 +1354,16 @@ begin_location_change (NautilusWindowSlot *self, nautilus_window_slot_set_allow_stop (self, TRUE); - new_selection = check_select_old_location_containing_folder (new_selection, location, previous_location); - g_assert (self->pending_location == NULL); self->pending_location = g_object_ref (location); self->location_change_type = type; self->location_change_distance = distance; self->tried_mount = FALSE; - self->pending_selection = nautilus_file_list_copy (new_selection); + self->pending_selection = + check_select_old_location_containing_folder (nautilus_file_list_copy (new_selection), + location, + previous_location); self->pending_scroll_to = g_strdup (scroll_pos); -- cgit v1.2.1