The python xpathEval convenience method on xmlCore leaks an xmlXPathContext if the expression is invalid or otherwise fails. Fix attached, with test that can probably be adapted to go in the tests dir.
I'd like to do a real fix for the xpathEval2 thing just below, but it'd mean bindings changes, so then might as well rewrite cleaner... spirals into a big job. Martin
simple_leak.patch
Description: Binary data
import libxml2
libxml2.debugMemory(True)
d = libxml2.parseDoc("<fish/>")
for expr in ("/fish[.=$var]", "local-name('one','two')", "~?)%^*("):
try:
result = d.xpathEval(expr)
except libxml2.xpathError, e:
print "xpathError raised:", e
else:
raise ValueError("Unexpected success", expr, result)
d.freeDoc()
libxml2.cleanupParser()
leakedbytes = libxml2.debugMemory(True)
if leakedbytes == 0:
print "OK"
else:
print "Memory leak", leakedbytes, "bytes"
# drop file to .memdump file in cwd, but won't work if not compiled in
libxml2.dumpMemory()
_______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
