From b690ac32c1cf8e2f134e76743770f25e0400b821 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Thu, 16 Mar 2017 12:53:13 +0000 Subject: [PATCH] Test group with many elements and a failing reallocator --- expat/tests/runtests.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 02e951ea..768902d1 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -6917,6 +6917,45 @@ START_TEST(test_alloc_realloc_nested_groups) #undef MAX_REALLOC_COUNT END_TEST +START_TEST(test_alloc_realloc_group_choice) +{ + const char *text = + "\n" + "]>\n" + "\n" + "\n" + "This is a foo\n" + "\n" + "\n"; + int i; +#define MAX_REALLOC_COUNT 10 + + for (i = 0; i < MAX_REALLOC_COUNT; i++) { + reallocation_count = i; + XML_SetElementDeclHandler(parser, dummy_element_decl_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 succeeded despite failing reallocator"); + if (i == MAX_REALLOC_COUNT) + fail("Parse failed at maximum reallocation count"); + if (dummy_handler_flags != DUMMY_ELEMENT_DECL_HANDLER_FLAG) + fail("Element handler flag not raised"); +} +#undef MAX_REALLOC_COUNT +END_TEST + START_TEST(test_standalone_parameter_entity) { const char *text = @@ -7722,6 +7761,7 @@ make_suite(void) tcase_add_test(tc_alloc, test_alloc_system_notation); tcase_add_test(tc_alloc, test_alloc_nested_groups); tcase_add_test(tc_alloc, test_alloc_realloc_nested_groups); + tcase_add_test(tc_alloc, test_alloc_realloc_group_choice); suite_add_tcase(s, tc_nsalloc); tcase_add_checked_fixture(tc_nsalloc, nsalloc_setup, nsalloc_teardown);