From a7b6aea3767ae2b22509d2b801e53055aafe085c Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Wed, 26 Apr 2017 14:46:33 +0100 Subject: [PATCH] Test processing instruction with long body and duff allocator --- expat/tests/runtests.c | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 279fc4f2..cd71d4f5 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -5999,6 +5999,48 @@ START_TEST(test_alloc_parse_pi_2) } END_TEST +START_TEST(test_alloc_parse_pi_3) +{ + const char *text = + ""; + int i; +#define MAX_ALLOC_COUNT 10 + + for (i = 0; i < MAX_ALLOC_COUNT; i++) { + /* Every allocation bar the last is cached */ + allocation_count = (i == 0) ? 0 : 1; + XML_SetProcessingInstructionHandler(parser, dummy_pi_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 failing allocator"); + if (i == MAX_ALLOC_COUNT) + fail("Parse failed with max allocations"); +} +#undef MAX_ALLOC_COUNT +END_TEST + START_TEST(test_alloc_parse_comment) { const char *text = @@ -7938,7 +7980,6 @@ START_TEST(test_alloc_realloc_ce_extends_pe) #undef MAX_REALLOC_COUNT END_TEST - static void nsalloc_setup(void) { @@ -8715,6 +8756,7 @@ make_suite(void) tcase_add_test(tc_alloc, test_alloc_parse_xdecl_2); tcase_add_test(tc_alloc, test_alloc_parse_pi); tcase_add_test(tc_alloc, test_alloc_parse_pi_2); + tcase_add_test(tc_alloc, test_alloc_parse_pi_3); tcase_add_test(tc_alloc, test_alloc_parse_comment); tcase_add_test(tc_alloc, test_alloc_parse_comment_2); tcase_add_test(tc_alloc, test_alloc_create_external_parser);