]> granicus.if.org Git - libexpat/commitdiff
Make test_alloc_internal_entity() robust vs allocation pattern changes
authorRhodri James <rhodri@kynesim.co.uk>
Thu, 27 Jul 2017 11:38:47 +0000 (12:38 +0100)
committerRhodri James <rhodri@kynesim.co.uk>
Thu, 27 Jul 2017 12:02:44 +0000 (13:02 +0100)
expat/tests/runtests.c

index 468f0c11c06af0626d01de49e0d8a71ebba40dee..4cc5bcf5b788565bf0610da4cc414cab460378f7 100644 (file)
@@ -8427,27 +8427,25 @@ START_TEST(test_alloc_internal_entity)
         "<!DOCTYPE test [<!ENTITY foo 'bar'>]>\n"
         "<test a='&foo;'/>";
     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