Validate parser parameter to XML_GetIdAttributeIndex
diff --git a/expat/lib/expat.h b/expat/lib/expat.h
index 7ae0f4c..4c9e3a1 100644
--- a/expat/lib/expat.h
+++ b/expat/lib/expat.h
@@ -738,9 +738,10 @@
XML_GetSpecifiedAttributeCount(XML_Parser parser);
/* Returns the index of the ID attribute passed in the last call to
- XML_StartElementHandler, or -1 if there is no ID attribute. Each
- attribute/value pair counts as 2; thus this correspondds to an
- index into the atts array passed to the XML_StartElementHandler.
+ XML_StartElementHandler, or -1 if there is no ID attribute or
+ parser == NULL. Each attribute/value pair counts as 2; thus this
+ correspondds to an index into the atts array passed to the
+ XML_StartElementHandler.
*/
XMLPARSEAPI(int)
XML_GetIdAttributeIndex(XML_Parser parser);
diff --git a/expat/lib/xmlparse.c b/expat/lib/xmlparse.c
index 0165635..d199356 100644
--- a/expat/lib/xmlparse.c
+++ b/expat/lib/xmlparse.c
@@ -1362,6 +1362,8 @@
int XMLCALL
XML_GetIdAttributeIndex(XML_Parser parser)
{
+ if (parser == NULL)
+ return -1;
return idAttIndex;
}