]> granicus.if.org Git - libexpat/commitdiff
Make test_alloc_ext_entity_realloc_buffer() robust vs allocations
authorRhodri James <rhodri@kynesim.co.uk>
Thu, 27 Jul 2017 12:20:42 +0000 (13:20 +0100)
committerRhodri James <rhodri@kynesim.co.uk>
Thu, 27 Jul 2017 12:20:42 +0000 (13:20 +0100)
expat/tests/runtests.c

index 9c5c44b8751a7af618d32b934237f695c4dcaf17..bb963fc3ab01d7fb2a261afe4ae86345f1d7ec30 100644 (file)
@@ -8626,21 +8626,25 @@ START_TEST(test_alloc_ext_entity_realloc_buffer)
         "]>\n"
         "<doc>&en;</doc>";
     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 */