Skip to content

Instantly share code, notes, and snippets.

@seb-m
Created September 26, 2011 20:24
Show Gist options
  • Save seb-m/1243302 to your computer and use it in GitHub Desktop.
Save seb-m/1243302 to your computer and use it in GitHub Desktop.
XPathQuery leak
--- /Volumes/Sam500/Download/XPathQuery.m 2011-09-26 22:17:18.000000000 +0200
+++ Hpple/XPathQuery.m 2011-09-26 22:14:07.000000000 +0200
@@ -121,6 +121,7 @@
xpathObj = xmlXPathEvalExpression((xmlChar *)[query cStringUsingEncoding:NSUTF8StringEncoding], xpathCtx);
if(xpathObj == NULL) {
NSLog(@"Unable to evaluate XPath.");
+ xmlXPathFreeContext(xpathCtx);
return nil;
}
@@ -128,6 +129,8 @@
if (!nodes)
{
NSLog(@"Nodes was nil.");
+ xmlXPathFreeObject(xpathObj);
+ xmlXPathFreeContext(xpathCtx);
return nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment