From 10d82fc892a11d0f17491f21562570b81713b068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Fernandes?= Date: Wed, 16 Dec 2020 13:47:17 +0000 Subject: properties-window: Stop multi-file GAppInfo leak When showing the properties for multiple files with the same MIME type, The app_info variable is reassigned multiple times in a for loop to the return value of nautilus_mime_get_default_application_for_file(), which returns a caller-owned refference. So, we leak a reference on each reassignment. To fix this, declare the variable inside the loop block, to ensure autocleanup after each loop iteration. --- src/nautilus-properties-window.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c index 35432664d..208af5171 100644 --- a/src/nautilus-properties-window.c +++ b/src/nautilus-properties-window.c @@ -4373,7 +4373,6 @@ should_show_open_with (NautilusPropertiesWindow *self) g_autofree gchar *mime_type = NULL; g_autofree gchar *extension = NULL; gboolean hide; - g_autoptr (GAppInfo) app_info = NULL; /* Don't show open with tab for desktop special icons (trash, etc) * or desktop files. We don't get the open-with menu for these anyway. @@ -4394,6 +4393,8 @@ should_show_open_with (NautilusPropertiesWindow *self) for (l = self->target_files; l; l = l->next) { + g_autoptr (GAppInfo) app_info = NULL; + file = NAUTILUS_FILE (l->data); app_info = nautilus_mime_get_default_application_for_file (file); if (nautilus_file_is_directory (file) || !app_info || file == NULL) @@ -4408,8 +4409,9 @@ should_show_open_with (NautilusPropertiesWindow *self) } else { - file = get_target_file (self); + g_autoptr (GAppInfo) app_info = NULL; + file = get_target_file (self); app_info = nautilus_mime_get_default_application_for_file (file); if (nautilus_file_is_directory (file) || !app_info || file == NULL) { -- cgit v1.2.1