summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2020-12-16 13:47:17 +0000
committerAntónio Fernandes <antoniof@gnome.org>2020-12-17 19:03:22 +0000
commitac601e4c597b2aadb197e6732d91649c6a371781 (patch)
tree26420a316b2b78e3893fd3b41db78c5a154d8dfc
parent28723cda5e3ad2e9c45680fbdc4a6dc1a1e02d33 (diff)
downloadnautilus-ac601e4c597b2aadb197e6732d91649c6a371781.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.c6
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)
{