
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1194918780 28800 # Node ID 8b6965d9e9479dab28337480e1f84812d2c880f2 # Parent 4ceb57b4430b0455ef7cb68f57a8ec6ad01abeca This fixes a potential crash if _get_domain() is unable to properly parse the dom XML. Also fixes an issue in VSSD - if get_domaininfo() returns 0 (an error), then instance_from_dom() needs to set ret properly so that an empty instance won't be created. Previous patch had a memory leak - fixed this issue. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 4ceb57b4430b -r 8b6965d9e947 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Mon Nov 12 13:54:53 2007 -0800 +++ b/libxkutil/device_parsing.c Mon Nov 12 17:53:00 2007 -0800 @@ -575,16 +575,24 @@ int get_dominfo(virDomainPtr dom, struct xml = virDomainGetXMLDesc(dom, 0); if (!xml) { free(*dominfo); + *dominfo = NULL; return 0; } ret = _get_dominfo(xml, *dominfo); - free(xml); + if (!ret) { + free(*dominfo); + *dominfo = NULL; + goto out; + } (*dominfo)->dev_mem_ct = get_mem_devices(dom, &(*dominfo)->dev_mem); (*dominfo)->dev_net_ct = get_net_devices(dom, &(*dominfo)->dev_net); (*dominfo)->dev_disk_ct = get_disk_devices(dom, &(*dominfo)->dev_disk); (*dominfo)->dev_vcpu_ct = get_vcpu_devices(dom, &(*dominfo)->dev_vcpu); + +out: + free(xml); return ret; } diff -r 4ceb57b4430b -r 8b6965d9e947 src/Virt_VSSD.c --- a/src/Virt_VSSD.c Mon Nov 12 13:54:53 2007 -0800 +++ b/src/Virt_VSSD.c Mon Nov 12 17:53:00 2007 -0800 @@ -45,7 +45,8 @@ static int instance_from_dom(virDomainPt CMPIObjectPath *op; struct domain *dominfo = NULL; - if (!get_dominfo(dom, &dominfo)) + ret = get_dominfo(dom, &dominfo); + if (!ret) goto out; op = CMGetObjectPath(inst, NULL);