]> granicus.if.org Git - libexpat/commitdiff
Extend tests to XML_GetBuffer in various circumstances
authorRhodri James <rhodri@kynesim.co.uk>
Tue, 7 Feb 2017 15:12:55 +0000 (15:12 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 5 Mar 2017 21:44:17 +0000 (22:44 +0100)
expat/tests/runtests.c

index 8ef4df1c9d695bd2952e6284885997e355dbe7da..eccc821e64a798fd640f0d0b6f279b7c18794d84 100644 (file)
@@ -2473,6 +2473,10 @@ START_TEST(test_misc_alloc_ns_parse_buffer)
     if (XML_ParseBuffer(parser, 0, XML_FALSE) != XML_STATUS_OK)
         xml_failure(parser);
 
+    /* Try silly buffer lengths */
+    if (XML_GetBuffer(parser, -12) != NULL)
+        fail("Negative length buffer not failed");
+
     /* Get the parser into suspended state */
     XML_SetCharacterDataHandler(parser, clearing_aborting_character_handler);
     resumable = XML_TRUE;
@@ -2489,6 +2493,8 @@ START_TEST(test_misc_alloc_ns_parse_buffer)
         fail("Suspended XML_ParseBuffer not faulted");
     if (XML_GetErrorCode(parser) != XML_ERROR_SUSPENDED)
         xml_failure(parser);
+    if (XML_GetBuffer(parser, strlen(text)) != NULL)
+        fail("Suspended XML_GetBuffer not faulted");
 
     /* Get it going again and complete the world */
     XML_SetCharacterDataHandler(parser, NULL);
@@ -2498,6 +2504,8 @@ START_TEST(test_misc_alloc_ns_parse_buffer)
         fail("Post-finishing XML_ParseBuffer not faulted");
     if (XML_GetErrorCode(parser) != XML_ERROR_FINISHED)
         xml_failure(parser);
+    if (XML_GetBuffer(parser, strlen(text)) != NULL)
+        fail("Post-finishing XML_GetBuffer not faulted");
 }
 END_TEST