fixed memory leak in xpath error reporting
* xpath.c: fixed memory leak in xpath error reporting
diff --git a/xpath.c b/xpath.c
index 4e373c0..8b23cac 100644
--- a/xpath.c
+++ b/xpath.c
@@ -368,6 +368,10 @@
xmlXPathErrorMessages[error]);
return;
}
+
+ /* cleanup current last error */
+ xmlResetError(&ctxt->context->lastError);
+
ctxt->context->lastError.domain = XML_FROM_XPATH;
ctxt->context->lastError.code = error + XML_XPATH_EXPRESSION_OK -
XPATH_EXPRESSION_OK;
@@ -1860,14 +1864,14 @@
*
* Creates/frees an object cache on the XPath context.
* If activates XPath objects (xmlXPathObject) will be cached internally
- * to be reused.
- * @options:
- * 0: This will set the XPath object caching:
- * @value:
- * This will set the maximum number of XPath objects
+ * to be reused.
+ * @options:
+ * 0: This will set the XPath object caching:
+ * @value:
+ * This will set the maximum number of XPath objects
* to be cached per slot
* There are 5 slots for: node-set, string, number, boolean, and
- * misc objects. Use <0 for the default number (100).
+ * misc objects. Use <0 for the default number (100).
* Other values for @options have currently no effect.
*
* Returns 0 if the setting succeeded, and -1 on API or internal errors.
@@ -1888,7 +1892,7 @@
if (ctxt->cache == NULL)
return(-1);
}
- cache = (xmlXPathContextCachePtr) ctxt->cache;
+ cache = (xmlXPathContextCachePtr) ctxt->cache;
if (options == 0) {
if (value < 0)
value = 100;
@@ -1896,7 +1900,7 @@
cache->maxString = value;
cache->maxNumber = value;
cache->maxBoolean = value;
- cache->maxMisc = value;
+ cache->maxMisc = value;
}
} else if (ctxt->cache != NULL) {
xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);