From: Ravi Sankar Guntur Date: Fri, 3 Feb 2012 18:44:56 +0000 (+0530) Subject: fix memory leak in g_bookmark_file_parse() X-Git-Tag: 2.31.16~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=59a0134de8ba98d05d97d8fcded4e86bac7fe606;p=platform%2Fupstream%2Fglib.git fix memory leak in g_bookmark_file_parse() https://bugzilla.gnome.org/show_bug.cgi?id=669334 Signed-off-by: Ravi Sankar Guntur --- diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c index 7f1422a..5b5ff50 100644 --- a/glib/gbookmarkfile.c +++ b/glib/gbookmarkfile.c @@ -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; } /**