The destructor of xpathTransformation appears to have a memory leak. The issue is in the conditional check for freeing the compiled_xpath.
Here is the current destructor code:
xpathTransformation::~xpathTransformation() {
// free the compiled xpath
if (!compiled_xpath)
xmlXPathFreeCompExpr(compiled_xpath);
// free the namespace for any added attributes
if (attr_ns)
xmlFreeNs(attr_ns);
// free the namespace for any added elements
if (element_ns)
xmlFreeNs(element_ns);
}
The problem is with this line:
if (!compiled_xpath)
xmlXPathFreeCompExpr(compiled_xpath);
The if (!compiled_xpath) check means that xmlXPathFreeCompExpr(compiled_xpath) is only called if compiled_xpath is NULL. However, we might want to free compiled_xpath when it is not NULL.
The issue was fixed by changing the line to:
if (compiled_xpath)
xmlXPathFreeCompExpr(compiled_xpath);
The destructor of xpathTransformation appears to have a memory leak. The issue is in the conditional check for freeing the compiled_xpath.
Here is the current destructor code:
The problem is with this line:
The if (!compiled_xpath) check means that xmlXPathFreeCompExpr(compiled_xpath) is only called if compiled_xpath is NULL. However, we might want to free compiled_xpath when it is not NULL.
The issue was fixed by changing the line to: