[glib/glib-2-30] fix memory leak in g_bookmark_file_parse()
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-30] fix memory leak in g_bookmark_file_parse()
- Date: Sun, 11 Mar 2012 22:23:14 +0000 (UTC)
commit 8ac2a93edcda9b9143d025fe15ec74964c500eb5
Author: Ravi Sankar Guntur <ravi g samsung com>
Date: Sat Feb 4 00:14:56 2012 +0530
fix memory leak in g_bookmark_file_parse()
https://bugzilla.gnome.org/show_bug.cgi?id=669334
Signed-off-by: Ravi Sankar Guntur <ravi g samsung com>
glib/gbookmarkfile.c | 48 ++++++++++++++++++++----------------------------
1 files changed, 20 insertions(+), 28 deletions(-)
---
diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c
index 0306bc2..7805bec 100644
--- a/glib/gbookmarkfile.c
+++ b/glib/gbookmarkfile.c
@@ -1438,9 +1438,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;
@@ -1451,6 +1451,9 @@ g_bookmark_file_parse (GBookmarkFile *bookmark,
if (!buffer)
return FALSE;
+
+ parse_error = NULL;
+ end_error = NULL;
if (length == (gsize) -1)
length = strlen (buffer);
@@ -1463,30 +1466,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 *
@@ -1705,14 +1700,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;
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]