From 7f4fdb59aa6963a066e251063dc6b7cfb766fdfe Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Wed, 8 Apr 2015 22:08:13 -0400 Subject: [PATCH] gsettings: fix schema compiler error handling Fix a couple of issues in error handling in glib-compile-schemas. The first problem is that, in case of repeated or tags we were still allocating a GString which was never being freed (due to the throwing of the error resulting in immediate termination of the parse). The second problem is that if the repeated tag also had attributes, we would attempt to set the GError twice. https://bugzilla.gnome.org/show_bug.cgi?id=747542 --- gio/glib-compile-schemas.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c index a09ceae95..2b3e0de9c 100644 --- a/gio/glib-compile-schemas.c +++ b/gio/glib-compile-schemas.c @@ -1383,27 +1383,33 @@ start_element (GMarkupParseContext *context, else if (strcmp (element_name, "summary") == 0) { - if (state->key_state->summary_seen && state->strict) - g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - _("Only one <%s> element allowed inside <%s>"), - element_name, container); - state->key_state->summary_seen = TRUE; - if (NO_ATTRS ()) - state->string = g_string_new (NULL); + { + if (state->key_state->summary_seen && state->strict) + g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + _("Only one <%s> element allowed inside <%s>"), + element_name, container); + else + state->string = g_string_new (NULL); + + state->key_state->summary_seen = TRUE; + } return; } else if (strcmp (element_name, "description") == 0) { - if (state->key_state->description_seen && state->strict) - g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, - _("Only one <%s> element allowed inside <%s>"), - element_name, container); - state->key_state->description_seen = TRUE; - if (NO_ATTRS ()) - state->string = g_string_new (NULL); + { + if (state->key_state->description_seen && state->strict) + g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, + _("Only one <%s> element allowed inside <%s>"), + element_name, container); + else + state->string = g_string_new (NULL); + + state->key_state->description_seen = TRUE; + } return; }