[Expat-checkins] expat/tests runtests.c,1.64,1.65

Fred L. Drake fdrake at users.sourceforge.net
Sat Jul 1 17:01:10 CEST 2006


Update of /cvsroot/expat/expat/tests
In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv7527/tests

Modified Files:
	runtests.c 
Log Message:
SF bug #1515266: missing check of stopped parser in doContext() for loop
(added regression test, closing bug report)


Index: runtests.c
===================================================================
RCS file: /cvsroot/expat/expat/tests/runtests.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- runtests.c	1 Jul 2006 02:34:50 -0000	1.64
+++ runtests.c	1 Jul 2006 15:01:00 -0000	1.65
@@ -983,6 +983,59 @@
 END_TEST
 
 
+static void
+self_clearing_aborting_character_handler(void *userData,
+                                         const XML_Char *s,
+                                         int len)
+{
+    XML_StopParser(parser, XML_FALSE);
+    XML_SetCharacterDataHandler(parser, NULL);
+}
+
+/* Regression test for SF bug #1515266: missing check of stopped
+   parser in doContext() 'for' loop. */
+START_TEST(test_stop_parser_between_char_data_calls)
+{
+    /* The sample data must be big enough that there are two calls to
+       the character data handler from within the inner "for" loop of
+       the XML_TOK_DATA_CHARS case in doContent(), and the character
+       handler must stop the parser and clear the character data
+       handler.
+    */
+    char *text =
+        "<?xml version='1.0' encoding='iso-8859-1'?><s>"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "012345678901234567890123456789012345678901234567890123456789"
+        "</s>";
+
+    XML_SetCharacterDataHandler(parser,
+                                self_clearing_aborting_character_handler);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) != XML_STATUS_ERROR)
+        xml_failure(parser);
+    if (XML_GetErrorCode(parser) != XML_ERROR_ABORTED)
+        xml_failure(parser);
+}
+END_TEST
+
+
 /*
  * Namespaces tests.
  */
@@ -1380,6 +1433,7 @@
     tcase_add_test(tc_basic, test_dtd_default_handling);
     tcase_add_test(tc_basic, test_empty_ns_without_namespaces);
     tcase_add_test(tc_basic, test_ns_in_attribute_default_without_namespaces);
+    tcase_add_test(tc_basic, test_stop_parser_between_char_data_calls);
 
     suite_add_tcase(s, tc_namespace);
     tcase_add_checked_fixture(tc_namespace,



More information about the Expat-checkins mailing list