Fix memory leaks in glib-compile resources
authorMatthias Clasen <mclasen@redhat.com>
Sun, 30 Sep 2012 18:07:37 +0000 (14:07 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 30 Sep 2012 18:07:37 +0000 (14:07 -0400)
Based on a patch by Josselin Mouette,
https://bugzilla.gnome.org/show_bug.cgi?id=685069

gio/glib-compile-resources.c

index fbe2c73..c712010 100644 (file)
@@ -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);
             }