[Libvirt-cim] [PATCH] This fixes a potential crash if _get_domain() is unable to properly parse the dom XML

Dan Smith danms at us.ibm.com
Tue Nov 13 00:57:04 UTC 2007


KR>          ret = _get_dominfo(xml, *dominfo);
KR> +        if (!ret) {
KR> +                free(*dominfo);
KR> +                *dominfo = NULL;
KR> +                return 0;
KR> +        }
KR> +
KR>          free(xml);

You've just introduced a memory leak here, since xml won't get
free()'d.  Just remove the "return 0" and let it fall through and it
should be fine.

KR> diff -r 4ceb57b4430b -r f29660709900 src/Virt_VSSD.c
KR> --- a/src/Virt_VSSD.c	Mon Nov 12 13:54:53 2007 -0800
KR> +++ b/src/Virt_VSSD.c	Mon Nov 12 16:15:41 2007 -0800
KR> @@ -45,7 +45,8 @@ static int instance_from_dom(virDomainPt
KR>          CMPIObjectPath *op;
KR>          struct domain *dominfo = NULL;

KR> -        if (!get_dominfo(dom, &dominfo))
KR> +        ret = get_dominfo(dom, &dominfo);
KR> +        if (!ret)
KR>                  goto out;

Maybe my eyes are tired at the end of the day, but does this fix
anything or is it just a style change?

-- 
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms at us.ibm.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20071112/887f3b2e/attachment.sig>


More information about the Libvirt-cim mailing list