]> granicus.if.org Git - libexpat/commitdiff
Validate parser parameter to XML_UseForeignDTD.
authorRhodri James <rhodri@kynesim.co.uk>
Tue, 25 Apr 2017 15:21:27 +0000 (16:21 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Wed, 24 May 2017 18:49:38 +0000 (20:49 +0200)
expat/lib/expat.h
expat/lib/xmlparse.c

index 086e24b39c51ae6df87e0485162dafced00c136b..957da1c552ae1984b08d56940ad10c20e9988c13 100644 (file)
@@ -95,7 +95,9 @@ enum XML_Error {
   /* Added in 2.0. */
   XML_ERROR_RESERVED_PREFIX_XML,
   XML_ERROR_RESERVED_PREFIX_XMLNS,
-  XML_ERROR_RESERVED_NAMESPACE_URI
+  XML_ERROR_RESERVED_NAMESPACE_URI,
+  /* Added in 2.2 */
+  XML_ERROR_INVALID_ARGUMENT
 };
 
 enum XML_Content_Type {
@@ -706,6 +708,7 @@ XML_UseParserAsHandlerArg(XML_Parser parser);
      be called, despite an external subset being parsed.
    Note: If XML_DTD is not defined when Expat is compiled, returns
      XML_ERROR_FEATURE_REQUIRES_XML_DTD.
+   Note: If parser == NULL, returns XML_ERROR_INVALID_ARGUMENT.
 */
 XMLPARSEAPI(enum XML_Error)
 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
index d00044bd332103d549933cf9c112f67b9d1ef17b..e0e39de9eb31a6b914fc7d6efecd7c45c34dadd2 100644 (file)
@@ -1292,6 +1292,8 @@ XML_UseParserAsHandlerArg(XML_Parser parser)
 enum XML_Error XMLCALL
 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD)
 {
+  if (parser == NULL)
+    return XML_ERROR_INVALID_ARGUMENT;
 #ifdef XML_DTD
   /* block after XML_Parse()/XML_ParseBuffer() has been called */
   if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED)