[glib] Fix memory leaks in glib-compile resources



commit 7f325939bae0a82f4d0f926f73f1002dbd4a0a11
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Sep 30 14:07:37 2012 -0400

    Fix memory leaks in glib-compile resources
    
    Based on a patch by Josselin Mouette,
    https://bugzilla.gnome.org/show_bug.cgi?id=685069

 gio/glib-compile-resources.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index fbe2c73..c712010 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -269,7 +269,6 @@ end_element (GMarkupParseContext  *context,
       if (state->preproc_options)
         {
           gchar **options;
-          gchar *stderr_child = NULL;
           guint i;
           gboolean xml_stripblanks = FALSE;
           gboolean to_pixdata = FALSE;
@@ -296,6 +295,7 @@ end_element (GMarkupParseContext  *context,
             {
               gchar *argv[8];
               int status, fd, argc;
+              gchar *stderr_child = NULL;
 
               tmp_file = g_strdup ("resource-XXXXXXXX");
               if ((fd = g_mkstemp (tmp_file)) == -1)
@@ -325,6 +325,7 @@ end_element (GMarkupParseContext  *context,
                                  G_SPAWN_STDOUT_TO_DEV_NULL,
                                  NULL, NULL, NULL, &stderr_child, &status, &my_error))
                 {
+                  g_free (stderr_child);
                   g_propagate_error (error, my_error);
                   goto cleanup;
                 }
@@ -334,10 +335,10 @@ end_element (GMarkupParseContext  *context,
                 {
                   g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                                _("Error processing input file with xmllint:\n%s"), stderr_child);
+                  g_free (stderr_child);
                   goto cleanup;
                 }
 
-              g_free (stderr_child);
               g_free (real_file);
               real_file = g_strdup (tmp_file);
             }
@@ -382,6 +383,7 @@ end_element (GMarkupParseContext  *context,
                                  NULL, NULL, NULL, &stderr_child, &status, &my_error))
                 {
                   g_propagate_error (error, my_error);
+                  g_free (stderr_child);
                   goto cleanup;
                 }
 	      
@@ -389,10 +391,10 @@ end_element (GMarkupParseContext  *context,
                 {
                   g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
 			       _("Error processing input file with to-pixdata:\n%s"), stderr_child);
+                  g_free (stderr_child);
                   goto cleanup;
                 }
 
-              g_free (stderr_child);
               g_free (real_file);
               real_file = g_strdup (tmp_file2);
             }



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