Re: leak fixes for gio



on., 14.11.2007 kl. 15.00 +0100, skrev Kjartan Maraas:
> Patch attached.
> 
Updated patch attached. I removed one too many g_free (trashname);
instances.

Cheers
Kjartan

Index: programs/gio-mount.c
===================================================================
--- programs/gio-mount.c	(revisjon 741)
+++ programs/gio-mount.c	(arbeidskopi)
@@ -185,6 +185,7 @@
   context = g_option_context_new ("- mount <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
   
   if (argc > 1)
     {
Index: programs/gio-monitor-dir.c
===================================================================
--- programs/gio-monitor-dir.c	(revisjon 741)
+++ programs/gio-monitor-dir.c	(arbeidskopi)
@@ -43,8 +43,13 @@
 		      GFile* other_file,
 		      GFileMonitorEvent eflags)
 {
+
+  char *name = g_file_get_parse_name (child);
+
   g_print ("Directory Monitor Event:\n");
-  g_print ("Child = %s\n", g_file_get_parse_name (child));
+  g_print ("Child = %s\n", name);
+  g_free (name);
+
   switch (eflags)
     {
     case G_FILE_MONITOR_EVENT_CHANGED:
@@ -89,6 +94,7 @@
   context = g_option_context_new ("- monitor directory <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
   
   if (argc > 1)
     {
Index: programs/gio-monitor-file.c
===================================================================
--- programs/gio-monitor-file.c	(revisjon 741)
+++ programs/gio-monitor-file.c	(arbeidskopi)
@@ -89,6 +89,7 @@
   context = g_option_context_new ("- monitor file <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
   
   if (argc > 1)
     {
Index: programs/gio-move.c
===================================================================
--- programs/gio-move.c	(revisjon 741)
+++ programs/gio-move.c	(arbeidskopi)
@@ -87,6 +87,7 @@
   context = g_option_context_new ("- output files at <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
 
   if (argc <= 2)
     {
Index: programs/gio-cat.c
===================================================================
--- programs/gio-cat.c	(revisjon 741)
+++ programs/gio-cat.c	(arbeidskopi)
@@ -111,6 +111,7 @@
   context = g_option_context_new ("- output files at <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
   
   if (argc > 1)
     {
Index: programs/gio-copy.c
===================================================================
--- programs/gio-copy.c	(revisjon 741)
+++ programs/gio-copy.c	(arbeidskopi)
@@ -91,6 +91,7 @@
   context = g_option_context_new ("- output files at <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
 
   if (argc <= 2)
     {
Index: programs/gio-info.c
===================================================================
--- programs/gio-info.c	(revisjon 741)
+++ programs/gio-info.c	(arbeidskopi)
@@ -329,7 +329,8 @@
   context = g_option_context_new ("- show info for <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
-  
+  g_option_context_free (context);
+ 
   if (argc > 1)
     {
       int i;
Index: programs/gio-ls.c
===================================================================
--- programs/gio-ls.c	(revisjon 741)
+++ programs/gio-ls.c	(arbeidskopi)
@@ -175,6 +175,7 @@
   context = g_option_context_new ("- list files at <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
 
   attributes = g_strconcat (G_FILE_ATTRIBUTE_STD_NAME "," G_FILE_ATTRIBUTE_STD_TYPE "," G_FILE_ATTRIBUTE_STD_SIZE,
 			    attributes != NULL ? "," : "",
Index: programs/gio-rm.c
===================================================================
--- programs/gio-rm.c	(revisjon 741)
+++ programs/gio-rm.c	(arbeidskopi)
@@ -48,6 +48,7 @@
   context = g_option_context_new ("- delete files");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
   
   if (argc > 1)
     {
Index: programs/gio-save.c
===================================================================
--- programs/gio-save.c	(revisjon 741)
+++ programs/gio-save.c	(arbeidskopi)
@@ -155,6 +155,7 @@
   context = g_option_context_new ("- output files at <location>");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
 
   res = FALSE;
   
Index: programs/gio-trash.c
===================================================================
--- programs/gio-trash.c	(revisjon 741)
+++ programs/gio-trash.c	(arbeidskopi)
@@ -48,6 +48,7 @@
   context = g_option_context_new ("- move files to trash");
   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
   g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
   
   if (argc > 1)
     {
Index: gio/glocalfileinfo.c
===================================================================
--- gio/glocalfileinfo.c	(revisjon 741)
+++ gio/glocalfileinfo.c	(arbeidskopi)
@@ -1207,6 +1207,7 @@
       if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
 	g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED, TRUE);
     }
+  g_free (basename);
   g_free (filename);
 }
 
@@ -1393,6 +1394,7 @@
       name = get_username_from_uid (statbuf.st_uid);
       if (name)
 	g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_USER, name);
+      g_free (name);
     }
 
   if (g_file_attribute_matcher_matches (attribute_matcher,
@@ -1403,6 +1405,7 @@
       name = get_realname_from_uid (statbuf.st_uid);
       if (name)
 	g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_USER_REAL, name);
+      g_free (name);
     }
   
   if (g_file_attribute_matcher_matches (attribute_matcher,
@@ -1413,6 +1416,7 @@
       name = get_groupname_from_gid (statbuf.st_gid);
       if (name)
 	g_file_info_set_attribute_string (info, G_FILE_ATTRIBUTE_OWNER_GROUP, name);
+      g_free (name);
     }
 
   if (parent_info && parent_info->device != 0 &&
Index: gio/gdesktopappinfo.c
===================================================================
--- gio/gdesktopappinfo.c	(revisjon 741)
+++ gio/gdesktopappinfo.c	(arbeidskopi)
@@ -1859,9 +1859,7 @@
   
   return;
  error:
-  if (filename)
-    g_free (filename);
-  
+  g_free (filename);
   g_key_file_free (key_file);
   
   if (mime_types != NULL)
@@ -1941,9 +1939,7 @@
   
   return;
  error:
-  if (filename)
-    g_free (filename);
-  
+  g_free (filename);
   g_key_file_free (key_file);
   
   if (mime_types != NULL)
Index: gio/glocaldirectorymonitor.c
===================================================================
--- gio/glocaldirectorymonitor.c	(revisjon 741)
+++ gio/glocaldirectorymonitor.c	(arbeidskopi)
@@ -46,8 +46,7 @@
   GLocalDirectoryMonitor* local_monitor;
   local_monitor = G_LOCAL_DIRECTORY_MONITOR (object);
 
-  if (local_monitor->dirname)
-    g_free (local_monitor->dirname);
+  g_free (local_monitor->dirname);
 
   if (local_monitor->mount_monitor)
     {
Index: gio/inotify/inotify-sub.c
===================================================================
--- gio/inotify/inotify-sub.c	(revisjon 741)
+++ gio/inotify/inotify-sub.c	(arbeidskopi)
@@ -62,9 +62,7 @@
 void
 _ih_sub_free (inotify_sub* sub)
 {
-  if (sub->dirname)
-    g_free (sub->dirname);
-  if (sub->filename)
-    g_free (sub->filename);
+  g_free (sub->dirname);
+  g_free (sub->filename);
   g_free (sub);
 }
Index: gio/glocalfile.c
===================================================================
--- gio/glocalfile.c	(revisjon 741)
+++ gio/glocalfile.c	(arbeidskopi)
@@ -1492,11 +1492,13 @@
     fd = open (infofile, O_CREAT | O_EXCL, 0666);
   } while (fd == -1 && errno == EEXIST);
 
+  g_free (basename);
+  g_free (infodir);
+
   if (fd == -1)
     {
       g_free (filesdir);
       g_free (topdir);
-      g_free (infodir);
       g_free (trashname);
       g_free (infofile);
       
@@ -1519,7 +1521,6 @@
   if (g_rename (local->filename, trashfile) == -1)
     {
       g_free (topdir);
-      g_free (infodir);
       g_free (trashname);
       g_free (infofile);
       g_free (trashfile);
@@ -1555,8 +1556,10 @@
 
   g_file_set_contents (infofile, data, -1, NULL);
   g_free (infofile);
+  g_free (data);
   
   g_free (original_name_escaped);
+  g_free (trashname);
   
   return TRUE;
 }


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