From 11739c13da9f4c2c71d79a372c6328fa7e97b4f0 Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Thu, 27 Jul 2017 13:20:42 +0100 Subject: [PATCH] Make test_alloc_ext_entity_realloc_buffer() robust vs allocations --- expat/tests/runtests.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index 9c5c44b8..bb963fc3 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -8626,21 +8626,25 @@ START_TEST(test_alloc_ext_entity_realloc_buffer) "]>\n" "&en;"; int i; +#define MAX_REALLOC_COUNT 10 - for (i = 0; i < 10; i++) { + for (i = 0; i < MAX_REALLOC_COUNT; i++) { XML_SetExternalEntityRefHandler(parser, external_entity_reallocator); XML_SetUserData(parser, (void *)(intptr_t)i); if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text), XML_TRUE) == XML_STATUS_OK) break; - XML_ParserReset(parser, NULL); + /* See comment in test_alloc_parse_xdecl() */ + alloc_teardown(); + alloc_setup(); } if (i == 0) fail("Succeeded with no reallocations"); - if (i == 10) - fail("Failed with 10 reallocations"); + if (i == MAX_REALLOC_COUNT) + fail("Failed with max reallocations"); } +#undef MAX_REALLOC_COUNT END_TEST /* Test elements with many attributes are handled correctly */ -- 2.40.0