From 52970d4a533c101e06c09ddbcf72b34e6aeb7c76 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Wed, 26 Jul 2017 18:29:06 +0100 Subject: [PATCH] Make test_alloc_parse_xdecl() robust vs allocation pattern changes --- expat/tests/runtests.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 59a426fa..93aae882 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -7846,25 +7846,21 @@ START_TEST(test_alloc_parse_xdecl) "\n" "Hello, world"; int i; - int repeat = 0; -#define MAX_ALLOC_COUNT 10 +#define MAX_ALLOC_COUNT 15 for (i = 0; i < MAX_ALLOC_COUNT; i++) { - /* Repeat some (most) counts to defeat cached allocations */ - if (i == 2 && repeat != 1) { - i--; - repeat++; - } - else if (i == 3) { - i -= 2; - repeat++; - } allocation_count = i; XML_SetXmlDeclHandler(parser, dummy_xdecl_handler); if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), XML_TRUE) != XML_STATUS_ERROR) break; - XML_ParserReset(parser, NULL); + /* Resetting the parser is insufficient, because some memory + * allocations are cached within the parser. Instead we use + * the teardown and setup routines to ensure that we have the + * right sort of parser back in our hands. + */ + alloc_teardown(); + alloc_setup(); } if (i == 0) fail("Parse succeeded despite failing allocator"); -- 2.40.0