[nautilus/gnome-3-36] file: Fix reference leak



commit 878778188af18eaac277316f76b93c72c61fe509
Author: António Fernandes <antoniof gnome org>
Date:   Sun May 17 14:27:23 2020 +0000

    file: Fix reference leak
    
    We are missing a "nautilus_file_unref(parent);" statement is missing in
    the get_filesystem_remote() method, leaking a reference.
    
    This was detected by a failing self-check test in a branch:
    https://gitlab.gnome.org/GNOME/nautilus/-/jobs/720894
    
    Let's fix this with autocleanup.
    
    For consistency, change the neighboor get_filesystem_type() to use
    autocleanup too, instead of the explicit nautilus_file_unref().
    
    
    (cherry picked from commit 9ef5d8344bf8355eceff291d9cd7029b532b9933)

 src/nautilus-file.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 8a482d447c..c9e557bd93 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -4665,7 +4665,6 @@ nautilus_file_get_filesystem_use_preview (NautilusFile *file)
 char *
 nautilus_file_get_filesystem_type (NautilusFile *file)
 {
-    NautilusFile *parent;
     char *filesystem_type = NULL;
 
     g_assert (NAUTILUS_IS_FILE (file));
@@ -4676,11 +4675,12 @@ nautilus_file_get_filesystem_type (NautilusFile *file)
     }
     else
     {
+        g_autoptr (NautilusFile) parent = NULL;
+
         parent = nautilus_file_get_parent (file);
         if (parent != NULL)
         {
             filesystem_type = g_strdup (parent->details->filesystem_type);
-            nautilus_file_unref (parent);
         }
     }
 
@@ -4690,8 +4690,6 @@ nautilus_file_get_filesystem_type (NautilusFile *file)
 gboolean
 nautilus_file_get_filesystem_remote (NautilusFile *file)
 {
-    NautilusFile *parent;
-
     g_assert (NAUTILUS_IS_FILE (file));
 
     if (nautilus_file_is_directory (file))
@@ -4700,6 +4698,8 @@ nautilus_file_get_filesystem_remote (NautilusFile *file)
     }
     else
     {
+        g_autoptr (NautilusFile) parent = NULL;
+
         parent = nautilus_file_get_parent (file);
         if (parent != NULL)
         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]