From 6ae8e2777eb87ba375b8e743fcb37d1f9dddf71a Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Fri, 10 Mar 2017 17:33:16 +0000 Subject: [PATCH] Test public notation with long system ID against failing allocator --- expat/tests/runtests.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 0f2f4e39..ba92c2a6 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -6345,6 +6345,62 @@ START_TEST(test_alloc_notation) #undef MAX_ALLOC_COUNT END_TEST +/* Test public notation with dodgy allocator */ +START_TEST(test_alloc_public_notation) +{ + const char *text = + "\n" + "\n" + "\n" + "]>\n"; + int i; +#define MAX_ALLOC_COUNT 10 + int repeat = 0; + + for (i = 0; i < MAX_ALLOC_COUNT; i++) { + /* Repeat some counts to allow for cached allocations */ + if ((i == 2 && repeat < 5) || + (i == 3 && repeat == 5)) { + i--; + repeat++; + } + allocation_count = i; + dummy_handler_flags = 0; + XML_SetNotationDeclHandler(parser, dummy_notation_decl_handler); + 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 allocation failures"); + if (i == MAX_ALLOC_COUNT) + fail("Parse failed at maximum allocation count"); + if (dummy_handler_flags != DUMMY_NOTATION_DECL_HANDLER_FLAG) + fail("Notation handler not called"); +} +#undef MAX_ALLOC_COUNT +END_TEST + static void nsalloc_setup(void) @@ -7116,6 +7172,7 @@ make_suite(void) tcase_add_test(tc_alloc, test_alloc_realloc_implied_attribute); tcase_add_test(tc_alloc, test_alloc_realloc_default_attribute); tcase_add_test(tc_alloc, test_alloc_notation); + tcase_add_test(tc_alloc, test_alloc_public_notation); suite_add_tcase(s, tc_nsalloc); tcase_add_checked_fixture(tc_nsalloc, nsalloc_setup, nsalloc_teardown); -- 2.40.0