]> granicus.if.org Git - libexpat/commitdiff
Extend code path coverage of entity handling
authorRhodri James <rhodri@kynesim.co.uk>
Tue, 14 Feb 2017 11:50:40 +0000 (11:50 +0000)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 16 Jul 2017 16:56:23 +0000 (18:56 +0200)
expat/tests/runtests.c

index fe5486cb061c48fe0c03acfac07a3045104ce705..6519fec4a617fb4339236948bc7d84ed71b79e83 100644 (file)
@@ -231,6 +231,11 @@ dummy_unparsed_entity_decl_handler(void *UNUSED_P(userData),
                                    const XML_Char *UNUSED_P(notationName))
 {}
 
+static void XMLCALL
+dummy_default_handler(void *UNUSED_P(userData),
+                      const XML_Char *UNUSED_P(s),
+                      int UNUSED_P(len))
+{}
 
 /*
  * Character & encoding tests.
@@ -1892,6 +1897,8 @@ START_TEST(test_set_foreign_dtd)
     XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
     XML_SetUserData(parser, dtd_text);
     XML_SetExternalEntityRefHandler(parser, external_entity_loader);
+    /* Add a default handler to exercise more code paths */
+    XML_SetDefaultHandler(parser, dummy_default_handler);
     if (XML_UseForeignDTD(parser, XML_TRUE) != XML_ERROR_NONE)
         fail("Could not set foreign DTD");
     if (_XML_Parse_SINGLE_BYTES(parser, text1, strlen(text1),