From df8c75ee2675d79f7c63bb8be69036841e2ac402 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Thu, 31 Aug 2017 13:09:05 +0100 Subject: [PATCH] Add test for issue #137: stopping parse doesn't always return an error This catches the case of stopping the parse on a single empty tag. There may be other cases where the parse status isn't checked properly. --- expat/tests/runtests.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 341a9e2d..10e9e529 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -5256,6 +5256,8 @@ start_element_suspender(void *UNUSED_P(userData), { if (!xcstrcmp(name, XCS("suspend"))) XML_StopParser(parser, XML_TRUE); + if (!xcstrcmp(name, XCS("abort"))) + XML_StopParser(parser, XML_FALSE); } START_TEST(test_suspend_resume_internal_entity) @@ -7065,6 +7067,17 @@ START_TEST(test_default_doctype_handler) } END_TEST +START_TEST(test_empty_element_abort) +{ + const char *text = ""; + + XML_SetStartElementHandler(parser, start_element_suspender); + if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), + XML_TRUE) != XML_STATUS_ERROR) + fail("Expected to error on abort"); +} +END_TEST + /* * Namespaces tests. */ @@ -12156,6 +12169,7 @@ make_suite(void) tcase_add_test(tc_basic, test_bad_entity_4); tcase_add_test(tc_basic, test_bad_notation); tcase_add_test(tc_basic, test_default_doctype_handler); + tcase_add_test(tc_basic, test_empty_element_abort); suite_add_tcase(s, tc_namespace); tcase_add_checked_fixture(tc_namespace, -- 2.40.0