fix memory leak in g_bookmark_file_parse()
authorRavi Sankar Guntur <ravi.g@samsung.com>
Fri, 3 Feb 2012 18:44:56 +0000 (00:14 +0530)
committerColin Walters <walters@verbum.org>
Sat, 4 Feb 2012 15:01:19 +0000 (10:01 -0500)
https://bugzilla.gnome.org/show_bug.cgi?id=669334

Signed-off-by: Ravi Sankar Guntur <ravi.g@samsung.com>
glib/gbookmarkfile.c

index 7f1422a..5b5ff50 100644 (file)
@@ -1418,9 +1418,9 @@ static const GMarkupParser markup_parser =
 
 static gboolean
 g_bookmark_file_parse (GBookmarkFile  *bookmark,
-                        const gchar      *buffer,
-                        gsize             length,
-                        GError          **error)
+                        const gchar  *buffer,
+                        gsize         length,
+                        GError       **error)
 {
   GMarkupParseContext *context;
   ParseData *parse_data;
@@ -1431,6 +1431,9 @@ g_bookmark_file_parse (GBookmarkFile  *bookmark,
 
   if (!buffer)
     return FALSE;
+
+  parse_error = NULL;
+  end_error = NULL;
   
   if (length == (gsize) -1)
     length = strlen (buffer);
@@ -1443,30 +1446,22 @@ g_bookmark_file_parse (GBookmarkFile  *bookmark,
                                        parse_data,
                                        (GDestroyNotify) parse_data_free);
   
-  parse_error = NULL;
   retval = g_markup_parse_context_parse (context,
                                         buffer,
                                         length,
                                         &parse_error);
   if (!retval)
-    {
-      g_propagate_error (error, parse_error);
-      
-      return FALSE;
-    }
-  
-  end_error = NULL;
-  retval = g_markup_parse_context_end_parse (context, &end_error);
-  if (!retval)
-    {
-      g_propagate_error (error, end_error);
-      
-      return FALSE;
-    }
-  
+    g_propagate_error (error, parse_error);
+  else
+   {
+     retval = g_markup_parse_context_end_parse (context, &end_error);
+      if (!retval)
+        g_propagate_error (error, end_error);
+   }
   g_markup_parse_context_free (context);
-  
-  return TRUE;
+
+  return retval;
 }
 
 static gchar *
@@ -1685,14 +1680,11 @@ g_bookmark_file_load_from_data (GBookmarkFile  *bookmark,
 
   parse_error = NULL;
   retval = g_bookmark_file_parse (bookmark, data, length, &parse_error);
+
   if (!retval)
-    {
-      g_propagate_error (error, parse_error);
-      
-      return FALSE;
-    }
-  
-  return TRUE;
+    g_propagate_error (error, parse_error);
+
+  return retval;
 }
 
 /**