gbookmarkfile: Fix some more minor leaks when metadata elements are repeated

oss-fuzz#9723

Signed-off-by: Philip Withnall <withnall@endlessm.com>
diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c
index 3f0275f..31706ba 100644
--- a/glib/gbookmarkfile.c
+++ b/glib/gbookmarkfile.c
@@ -863,7 +863,8 @@
       item->metadata->applications = g_list_prepend (item->metadata->applications, ai);
       g_hash_table_replace (item->metadata->apps_by_name, ai->name, ai);
     }
-      
+
+  g_free (ai->exec);
   ai->exec = g_strdup (exec);
   
   if (count)
diff --git a/glib/tests/Makefile.am b/glib/tests/Makefile.am
index 172d166..2087f83 100644
--- a/glib/tests/Makefile.am
+++ b/glib/tests/Makefile.am
@@ -165,6 +165,7 @@
 	bookmarks/fail-37.xbel \
 	bookmarks/fail-38.xbel \
 	bookmarks/fail-39.xbel \
+	bookmarks/fail-40.xbel \
 	bookmarks/valid-01.xbel \
 	bookmarks/valid-02.xbel \
 	bookmarks/valid-03.xbel \
diff --git a/glib/tests/bookmarks/fail-40.xbel b/glib/tests/bookmarks/fail-40.xbel
new file mode 100644
index 0000000..9ce48a8
--- /dev/null
+++ b/glib/tests/bookmarks/fail-40.xbel
@@ -0,0 +1 @@
+<xbel version="1.0"><bookmark href=""><info><metadata owner="http://freedesktop.org"><applications><application name=""exec=""/><application name=""exec=""/
\ No newline at end of file