[glib: 1/2] gbookmarkfile: Fix some minor leaks when metadata elements are repeated
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] gbookmarkfile: Fix some minor leaks when metadata elements are repeated
- Date: Thu, 2 Aug 2018 11:33:18 +0000 (UTC)
commit 6c041ff2831e8a34b8fa06b1f14340cd843fbc0a
Author: Philip Withnall <withnall endlessm com>
Date: Thu Aug 2 11:20:15 2018 +0100
gbookmarkfile: Fix some minor leaks when metadata elements are repeated
oss-fuzz#9674
Signed-off-by: Philip Withnall <withnall endlessm com>
glib/gbookmarkfile.c | 7 +++++--
glib/tests/Makefile.am | 1 +
glib/tests/bookmarks/fail-39.xbel | 1 +
3 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c
index e6f885e6b..3f0275fb9 100644
--- a/glib/gbookmarkfile.c
+++ b/glib/gbookmarkfile.c
@@ -915,7 +915,8 @@ parse_mime_type_element (GMarkupParseContext *context,
if (!item->metadata)
item->metadata = bookmark_metadata_new ();
-
+
+ g_free (item->metadata->mime_type);
item->metadata->mime_type = g_strdup (type);
}
@@ -964,7 +965,9 @@ parse_icon_element (GMarkupParseContext *context,
if (!item->metadata)
item->metadata = bookmark_metadata_new ();
-
+
+ g_free (item->metadata->icon_href);
+ g_free (item->metadata->icon_mime);
item->metadata->icon_href = g_strdup (href);
item->metadata->icon_mime = g_strdup (type);
}
diff --git a/glib/tests/Makefile.am b/glib/tests/Makefile.am
index 2a53ae6fd..172d16607 100644
--- a/glib/tests/Makefile.am
+++ b/glib/tests/Makefile.am
@@ -164,6 +164,7 @@ dist_test_data += \
bookmarks/fail-36.xbel \
bookmarks/fail-37.xbel \
bookmarks/fail-38.xbel \
+ bookmarks/fail-39.xbel \
bookmarks/valid-01.xbel \
bookmarks/valid-02.xbel \
bookmarks/valid-03.xbel \
diff --git a/glib/tests/bookmarks/fail-39.xbel b/glib/tests/bookmarks/fail-39.xbel
new file mode 100644
index 000000000..c57c83784
--- /dev/null
+++ b/glib/tests/bookmarks/fail-39.xbel
@@ -0,0 +1 @@
+<xbel version="1.0"><bookmark href=""><info><metadata owner="http://freedesktop.org"><mime-type/><mime-type/
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]