From: Rhodri James Date: Thu, 27 Jul 2017 12:16:13 +0000 (+0100) Subject: Make test_alloc_realloc_buffer() robust vs allocation pattern changes X-Git-Tag: R_2_2_3~16^2~37 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c18d7f9481339017b4817d4259ad1dbbb58fab7;p=libexpat Make test_alloc_realloc_buffer() robust vs allocation pattern changes --- diff --git a/expat/tests/runtests.c b/expat/tests/runtests.c index c13e9d1c..9c5c44b8 100644 --- a/expat/tests/runtests.c +++ b/expat/tests/runtests.c @@ -8565,15 +8565,10 @@ START_TEST(test_alloc_realloc_buffer) const char *text = get_buffer_test_text; void *buffer; int i; - int repeat = 0; +#define MAX_REALLOC_COUNT 10 /* Get a smallish buffer */ - for (i = 0; i < 10; i++) { - /* Repeat some indexes for cached allocations */ - if (repeat < 6 && i == 2) { - i--; - repeat++; - } + for (i = 0; i < MAX_REALLOC_COUNT; i++) { reallocation_count = i; buffer = XML_GetBuffer(parser, 1536); if (buffer == NULL) @@ -8582,14 +8577,17 @@ START_TEST(test_alloc_realloc_buffer) if (XML_ParseBuffer(parser, strlen(text), XML_FALSE) == XML_STATUS_OK) break; - XML_ParserReset(parser, NULL); + /* See comment in test_alloc_parse_xdecl() */ + alloc_teardown(); + alloc_setup(); } reallocation_count = -1; if (i == 0) fail("Parse succeeded with no reallocation"); - else if (i == 10) - fail("Parse failed with reallocation count 10"); + else if (i == MAX_REALLOC_COUNT) + fail("Parse failed with max reallocation count"); } +#undef MAX_REALLOC_COUNT END_TEST /* Same test for external entity parsers */