On Mon, Jul 30, 2007 at 10:14:25PM +0100, Daniel P. Berrange wrote:
I ran 'make valgrind' for the first time in too long and
found a hanful of
memory leaks in code exercised by the test suite. The attached patch fixes
them all.
I'm sure there are more lurking though - the test suite is mainly focused
on exercising & validating correctness of parsing routines - its not really
tried doing any validation of failure scenaarios. So I fear there's probably
a number of error code paths where we don't cleanup properly, and/or don't
reject invalid data. Its an area which should be addressed by someone with
some copious free time ;-)
Oops, sure looks fine to me !
--- src/xml.c 18 Jul 2007 21:08:22 -0000 1.85
+++ src/xml.c 30 Jul 2007 19:47:12 -0000
@@ -70,8 +70,11 @@ virXPathString(const char *xpath, xmlXPa
}
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
- (obj->stringval == NULL) || (obj->stringval[0] == 0))
+ (obj->stringval == NULL) || (obj->stringval[0] == 0)) {
+ if (obj)
+ xmlXPathFreeObject(obj);
return(NULL);
+ }
ret = strdup((char *) obj->stringval);
xmlXPathFreeObject(obj);
if (ret == NULL) {
And that one is mine, dohhh :-(
+1
Daniel
--
Red Hat Virtualization group
http://redhat.com/virtualization/
Daniel Veillard | virtualization library
http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/