]> granicus.if.org Git - libexpat/commitdiff
Test extension of URI buffer shared between element tags
authorRhodri James <rhodri@kynesim.co.uk>
Wed, 22 Feb 2017 18:41:31 +0000 (18:41 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 16 Jul 2017 17:00:24 +0000 (19:00 +0200)
expat/tests/runtests.c

index 7e06284f4bbda4834bf0e8e774fe936fbcb019ae..dd6cd68f5ad58d4cb72989b69d70ee4ec2984f99 100644 (file)
@@ -3567,6 +3567,23 @@ START_TEST(test_ns_mixed_prefix_atts)
 }
 END_TEST
 
+/* Test having a long namespaced element name inside a short one.
+ * This exercises some internal buffer reallocation that is shared
+ * across elements with the same namespace URI.
+ */
+START_TEST(test_ns_extend_uri_buffer)
+{
+    const char *text =
+        "<foo:e xmlns:foo='http://example.org/'>"
+        " <foo:thisisalongenoughnametotriggerallocationaction"
+        "   foo:a='12' />"
+        "</foo:e>";
+    if (_XML_Parse_SINGLE_BYTES(parser, text, strlen(text),
+                                XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
 
 /* Control variable; the number of times duff_allocator() will successfully allocate */
 #define ALLOC_ALWAYS_SUCCEED (-1)
@@ -5020,6 +5037,7 @@ make_suite(void)
     tcase_add_test(tc_namespace, test_ns_parser_reset);
     tcase_add_test(tc_namespace, test_ns_long_element);
     tcase_add_test(tc_namespace, test_ns_mixed_prefix_atts);
+    tcase_add_test(tc_namespace, test_ns_extend_uri_buffer);
 
     suite_add_tcase(s, tc_misc);
     tcase_add_checked_fixture(tc_misc, NULL, basic_teardown);