From 6c041ff2831e8a34b8fa06b1f14340cd843fbc0a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 2 Aug 2018 11:20:15 +0100 Subject: [PATCH] gbookmarkfile: Fix some minor leaks when metadata elements are repeated oss-fuzz#9674 Signed-off-by: Philip Withnall --- glib/gbookmarkfile.c | 7 +++++-- glib/tests/Makefile.am | 1 + glib/tests/bookmarks/fail-39.xbel | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 glib/tests/bookmarks/fail-39.xbel 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 @@ +