From 2253c1230496e38167dbddd0932bf307f11f7d1e Mon Sep 17 00:00:00 2001 From: Rhodri James Date: Tue, 25 Apr 2017 18:28:35 +0100 Subject: [PATCH] Validate the parser parameter to XML_GetCurrentByteIndex --- expat/lib/expat.h | 2 ++ expat/lib/xmlparse.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/expat/lib/expat.h b/expat/lib/expat.h index 2a06f35e..d2fc965f 100644 --- a/expat/lib/expat.h +++ b/expat/lib/expat.h @@ -942,6 +942,8 @@ XML_GetErrorCode(XML_Parser parser); the location is the location of the character at which the error was detected; otherwise the location is the location of the last parse event, as described above. + + Note: XML_GetCurrentByteIndex returns -1 to indicate an error. */ XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser); XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser); diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c index c64d0a64..c3df6ce6 100644 --- a/expat/lib/xmlparse.c +++ b/expat/lib/xmlparse.c @@ -2024,6 +2024,8 @@ XML_GetErrorCode(XML_Parser parser) XML_Index XMLCALL XML_GetCurrentByteIndex(XML_Parser parser) { + if (parser == NULL) + return -1; if (eventPtr) return (XML_Index)(parseEndByteIndex - (parseEndPtr - eventPtr)); return -1; -- 2.40.0