From 29bc47d2af8cb06d78e6258395e67b00afb40890 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Sun, 29 Jul 2018 20:16:23 +0100 Subject: [PATCH] Add regression test for issue #204, resume failure on empty input --- expat/tests/runtests.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index ff499ffe..0597d607 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -5199,6 +5199,34 @@ START_TEST(test_suspend_epilog) } END_TEST +static void XMLCALL +suspending_end_handler(void *userData, + const XML_Char *UNUSED_P(s)) +{ + XML_StopParser((XML_Parser)userData, 1); +} + +START_TEST(test_suspend_in_sole_empty_tag) +{ + const char *text = ""; + enum XML_Status rc; + + XML_SetEndElementHandler(parser, suspending_end_handler); + XML_SetUserData(parser, parser); + rc = _XML_Parse_SINGLE_BYTES(parser, text, (int)strlen(text), + XML_TRUE); + if (rc == XML_STATUS_ERROR) + xml_failure(parser); + else if (rc != XML_STATUS_SUSPENDED) + fail("Suspend not triggered"); + rc = XML_ResumeParser(parser); + if (rc == XML_STATUS_ERROR) + xml_failure(parser); + else if (rc != XML_STATUS_OK) + fail("Resume failed"); +} +END_TEST + START_TEST(test_unfinished_epilog) { const char *text = "<"; @@ -12094,6 +12122,7 @@ make_suite(void) tcase_add_test(tc_basic, test_abort_epilog); tcase_add_test(tc_basic, test_abort_epilog_2); tcase_add_test(tc_basic, test_suspend_epilog); + tcase_add_test(tc_basic, test_suspend_in_sole_empty_tag); tcase_add_test(tc_basic, test_unfinished_epilog); tcase_add_test(tc_basic, test_partial_char_in_epilog); tcase_add_test(tc_basic, test_hash_collision); -- 2.40.0