[glib/glib-2-22] Fix a memleak



commit aecd2616c78e82fcff49c584448a010da381f944
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jan 5 18:18:55 2010 -0500

    Fix a memleak
    
    An early exit in expand_application_parameters forgot to free
    a GString. Reported by Steve Grubb.
    (cherry picked from commit b00c6d7fb5798b4e528554e1221a553ab95506ed)

 gio/gdesktopappinfo.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index 98ad3d8..e9e82dd 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -701,16 +701,18 @@ expand_application_parameters (GDesktopAppInfo   *info,
 {
   GList *uri_list = *uris;
   const char *p = info->exec;
-  GString *expanded_exec = g_string_new (NULL);
+  GString *expanded_exec;
   gboolean res;
-  
+
   if (info->exec == NULL)
     {
       g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                            _("Desktop file didn't specify Exec field"));
       return FALSE;
     }
-  
+
+  expanded_exec = g_string_new (NULL);
+
   while (*p)
     {
       if (p[0] == '%' && p[1] != '\0')
@@ -720,10 +722,10 @@ expand_application_parameters (GDesktopAppInfo   *info,
 	}
       else
 	g_string_append_c (expanded_exec, *p);
-      
+
       p++;
     }
-  
+
   /* No file substitutions */
   if (uri_list == *uris && uri_list != NULL)
     {
@@ -731,7 +733,7 @@ expand_application_parameters (GDesktopAppInfo   *info,
       g_string_append_c (expanded_exec, ' ');
       expand_macro ('f', expanded_exec, info, uris);
     }
-  
+
   res = g_shell_parse_argv (expanded_exec->str, argc, argv, error);
   g_string_free (expanded_exec, TRUE);
   return res;



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