[glib] gio-tool: Various memory leak fixes



commit bde2bde41155cf4f60daea4c1cb60e3fc30e2d0d
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Dec 16 14:35:55 2016 +0100

    gio-tool: Various memory leak fixes
    
    https://bugzilla.gnome.org/show_bug.cgi?id=776169

 gio/gio-tool-info.c    |    1 +
 gio/gio-tool-monitor.c |    2 ++
 gio/gio-tool-set.c     |    7 +++++--
 3 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gio/gio-tool-info.c b/gio/gio-tool-info.c
index e21ef1b..d709693 100644
--- a/gio/gio-tool-info.c
+++ b/gio/gio-tool-info.c
@@ -254,6 +254,7 @@ get_writable_info (GFile *file)
                    list->infos[i].name,
                    attribute_type_to_string (list->infos[i].type),
                    (*flags != 0)?", ":"", flags);
+          g_free (flags);
         }
     }
 
diff --git a/gio/gio-tool-monitor.c b/gio/gio-tool-monitor.c
index c8ab04f..cfdcdbf 100644
--- a/gio/gio-tool-monitor.c
+++ b/gio/gio-tool-monitor.c
@@ -176,12 +176,14 @@ add_watch (const gchar       *cmdline,
     g_signal_connect (monitor, "changed", G_CALLBACK (watch_callback), g_strdup (cmdline));
 
   monitor = NULL; /* leak */
+  g_object_unref (file);
 
   return TRUE;
 
 err:
   print_file_error (file, error->message);
   g_error_free (error);
+  g_object_unref (file);
 
   return FALSE;
 }
diff --git a/gio/gio-tool-set.c b/gio/gio-tool-set.c
index d80aa23..e902b2b 100644
--- a/gio/gio-tool-set.c
+++ b/gio/gio-tool-set.c
@@ -112,8 +112,6 @@ handle_set (int argc, char *argv[], gboolean do_help)
       return 1;
     }
 
-  file = g_file_new_for_commandline_arg (argv[1]);
-
   if (argc < 3)
     {
       show_help (context, _("Attribute not specified"));
@@ -177,6 +175,8 @@ handle_set (int argc, char *argv[], gboolean do_help)
       return 1;
     }
 
+  file = g_file_new_for_commandline_arg (argv[1]);
+
   if (!g_file_set_attribute (file,
                             attribute,
                             type,
@@ -188,8 +188,11 @@ handle_set (int argc, char *argv[], gboolean do_help)
     {
       print_error (error->message);
       g_error_free (error);
+      g_object_unref (file);
       return 1;
     }
 
+  g_object_unref (file);
+
   return 0;
 }


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