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 <summary> or
<description> 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 <summary> tag also had
attributes, we would attempt to set the GError twice.

https://bugzilla.gnome.org/show_bug.cgi?id=747542
This commit is contained in:
Ryan Lortie 2015-04-08 22:08:13 -04:00
parent 2b8f131599
commit 7f4fdb59aa

View File

@ -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;
}