[xml] memory leak in xmlXPathErr?

Hello, All!

I believe I run into a memory leak in xmlXPathErr() with the
following (incorrect) XPath expression:


In this case, LibXML2 first reports an error from xmlXPathCompNodeTest()
function (some function parameters are removed in the stack trace):

 libxml2.dll!xmlStrdup()  Line 71
 libxml2.dll!xmlXPathErr()  Line 339
 libxml2.dll!xmlXPathCompNodeTest()  Line 8689
 libxml2.dll!xmlXPathCompStep()  Line 8940
 libxml2.dll!xmlXPathCompRelativeLocationPath()  Line 9072
 libxml2.dll!xmlXPathCompLocationPath()  Line 9072
 libxml2.dll!xmlXPathCompPathExpr()  Line 8288
 libxml2.dll!xmlXPathCompUnionExpr()  Line 8320
 libxml2.dll!xmlXPathCompUnaryExpr()  Line 8360
 libxml2.dll!xmlXPathCompMultiplicativeExpr()  Line 8385
 libxml2.dll!xmlXPathCompAdditiveExpr()  Line 8426
 libxml2.dll!xmlXPathCompRelationalExpr()  Line 8464
 libxml2.dll!xmlXPathCompEqualityExpr()  Line 8506
 libxml2.dll!xmlXPathCompAndExpr()  Line 8537
 libxml2.dll!xmlXPathCompileExpr()  Line 8563
 libxml2.dll!xmlXPathEvalExpr()  Line 11599
 libxml2.dll!xmlXPathEvalExpression("//billing/xtext()", 0x04f151bc)
                                 Line 11686

And then it re-reports this error again from xmlXPathEvalExpression()

 libxml2.dll!xmlStrdup()  Line 71
 libxml2.dll!xmlXPathErr()  Line 339
 libxml2.dll!xmlXPatherror()  Line 369
 libxml2.dll!xmlXPathEvalExpression("//billing/xtext()", 0x04f151bc)
                                 Line 11686

The proposed fix is trivial: just add one line to xmlXPathErr() function
right before the update "ctxt->context->lastError" variable:


Any objection if I make this change?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]