From 53a311d4dc8a5380f021225b6a37458e0bbb29c1 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Thu, 27 Jul 2017 12:38:47 +0100 Subject: [PATCH] Make test_alloc_internal_entity() robust vs allocation pattern changes --- expat/tests/runtests.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 468f0c11..4cc5bcf5 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -8427,27 +8427,25 @@ START_TEST(test_alloc_internal_entity) "]>\n" ""; unsigned int i; - int repeated = 0; +#define MAX_ALLOC_COUNT 20 - for (i = 0; i < 10; i++) { - /* Again, repeat some counts to account for caching */ - if (repeated < 2 && i == 2) { - i--; - repeated++; - } + for (i = 0; i < MAX_ALLOC_COUNT; i++) { + allocation_count = i; XML_SetUnknownEncodingHandler(parser, unknown_released_encoding_handler, NULL); - allocation_count = i; if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), XML_TRUE) != XML_STATUS_ERROR) break; - XML_ParserReset(parser, NULL); + /* See comment in test_alloc_parse_xdecl() */ + alloc_teardown(); + alloc_setup(); } if (i == 0) fail("Internal entity worked despite failing allocations"); - else if (i == 10) - fail("Internal entity failed at allocation count 10"); + else if (i == MAX_ALLOC_COUNT) + fail("Internal entity failed at max allocation count"); } +#undef MAX_ALLOC_COUNT END_TEST -- 2.49.0