From 1cab6d80f53afea56bc2876157e6288dd5dea349 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Thu, 16 Mar 2017 16:28:04 +0000 Subject: [PATCH] Test comment in epilog with failing allocator --- expat/tests/runtests.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index b03337d9..456e01e0 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -7077,6 +7077,44 @@ START_TEST(test_alloc_pi_in_epilog) #undef MAX_ALLOC_COUNT END_TEST +START_TEST(test_alloc_comment_in_epilog) +{ + const char *text = + "\n" + ""; + int i; +#define MAX_ALLOC_COUNT 10 + int repeat = 0; + + for (i = 0; i < MAX_ALLOC_COUNT; i++) { + /* Repeat certain counts to allow for cached allocations */ + if (i == 3 && repeat == 1) { + i -= 2; + repeat++; + } + else if (i == 2 && repeat < 4 && repeat != 1) { + i--; + repeat++; + } + allocation_count = i; + XML_SetCommentHandler(parser, dummy_comment_handler); + dummy_handler_flags = 0; + if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), + XML_TRUE) != XML_STATUS_ERROR) + break; + XML_ParserReset(parser, NULL); + } + if (i == 0) + fail("Parse completed despite failing allocator"); + if (i == MAX_ALLOC_COUNT) + fail("Parse failed at maximum allocation count"); + if (dummy_handler_flags != DUMMY_COMMENT_HANDLER_FLAG) + fail("Processing instruction handler not invoked"); +} +#undef MAX_ALLOC_COUNT +END_TEST + + static void nsalloc_setup(void) { @@ -7864,6 +7902,7 @@ make_suite(void) tcase_add_test(tc_alloc, test_alloc_realloc_nested_groups); tcase_add_test(tc_alloc, test_alloc_realloc_group_choice); tcase_add_test(tc_alloc, test_alloc_pi_in_epilog); + tcase_add_test(tc_alloc, test_alloc_comment_in_epilog); suite_add_tcase(s, tc_nsalloc); tcase_add_checked_fixture(tc_nsalloc, nsalloc_setup, nsalloc_teardown); -- 2.40.0