diff options
author | António Fernandes <antoniof@gnome.org> | 2020-12-16 13:47:17 +0000 |
---|---|---|
committer | Ondrej Holy <oholy@redhat.com> | 2020-12-22 09:58:52 +0000 |
commit | 10d82fc892a11d0f17491f21562570b81713b068 (patch) | |
tree | b193621db2c9d397383594e646d766c8b8ff95c3 | |
parent | 4a50c7dbeb381731b485234e30ceb45942a2e46e (diff) | |
download | nautilus-10d82fc892a11d0f17491f21562570b81713b068.tar.gz |
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.
-rw-r--r-- | src/nautilus-properties-window.c | 6 |
1 files 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) { |