[nautilus/wip/apoos-maximus/gsoc2020: 6/8] properties-window: Stop multi-file GAppInfo leak
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/apoos-maximus/gsoc2020: 6/8] properties-window: Stop multi-file GAppInfo leak
- Date: Thu, 17 Dec 2020 18:40:30 +0000 (UTC)
commit eb5aa4c21ee9d81a472b61ed8f198f419004c6ba
Author: António Fernandes <antoniof gnome org>
Date: Wed Dec 16 13:47:17 2020 +0000
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 f38da9103..f655a3829 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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]