fixed a memory leak on errors in some circumstances #159812 Daniel
* xpath.c: fixed a memory leak on errors in some circumstances #159812
Daniel
diff --git a/xpath.c b/xpath.c
index 8afbb34..20e38f4 100644
--- a/xpath.c
+++ b/xpath.c
@@ -3917,9 +3917,12 @@
*/
void
xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
+ if (ctxt == NULL) return;
+
xmlXPathRegisteredNsCleanup(ctxt);
xmlXPathRegisteredFuncsCleanup(ctxt);
xmlXPathRegisteredVariablesCleanup(ctxt);
+ xmlResetError(&ctxt->lastError);
xmlFree(ctxt);
}