#include <glib.h>

#define XML "<element a='1' b='2' c='3'/>"

static void
start_element (GMarkupParseContext *context,
               const gchar *element_name,
               const gchar **attribute_names,
               const gchar **attribute_values,
               gpointer user_data,
               GError **error)
{
	/* Omitting "c" attribute intentionally to trigger crash. */
	g_markup_collect_attributes (
		element_name,
		attribute_names,
		attribute_values,
		error,
		G_MARKUP_COLLECT_STRING,
		"a", NULL,
		G_MARKUP_COLLECT_STRING,
		"b", NULL,
		G_MARKUP_COLLECT_INVALID);
}

static GMarkupParser parser = {
	start_element
};

gint
main (gint argc, gchar **argv)
{
	GMarkupParseContext *context;

	context = g_markup_parse_context_new (&parser, 0, NULL, NULL);
	g_markup_parse_context_parse (context, XML, -1, NULL);
	g_markup_parse_context_end_parse (context, NULL);

	return 0;
}
