fixed problem with xmlXPathErr when error number subscript was out of
* xpath.c: fixed problem with xmlXPathErr when error number
subscript was out of range (bug 163055)
diff --git a/xpath.c b/xpath.c
index 2ea8c26..c075711 100644
--- a/xpath.c
+++ b/xpath.c
@@ -208,10 +208,11 @@
"Undefined namespace prefix\n",
"Encoding error\n",
"Char out of XML range\n",
- "Invalid or inclomplete context\n"
+ "Invalid or incomplete context\n",
+ "?? Unknown error ??\n" /* Must be last in the list! */
};
-
-
+#define MAXERRNO ((int)(sizeof(xmlXPathErrorMessages) / \
+ sizeof(xmlXPathErrorMessages[0])) - 1)
/**
* xmlXPathErrMemory:
* @ctxt: an XPath context
@@ -276,11 +277,13 @@
* @ctxt: a XPath parser context
* @error: the error code
*
- * Handle a Relax NG Parsing error
+ * Handle an XPath error
*/
void
xmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
{
+ if ((error < 0) || (error > MAXERRNO))
+ error = MAXERRNO;
if (ctxt == NULL) {
__xmlRaiseError(NULL, NULL, NULL,
NULL, NULL, XML_FROM_XPATH,