From: Hao Wang Date: Thu, 30 Jul 2020 12:03:08 +0000 (+0800) Subject: virNodeDevPCICapSRIOVVirtualParseXML: fix memleak of addr X-Git-Tag: v6.6.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7f5b86be25d27915cc67a8b84fa9a2589df4ab8;p=thirdparty%2Flibvirt.git virNodeDevPCICapSRIOVVirtualParseXML: fix memleak of addr virPCIDeviceAddressPtr 'addr' is forgotten to be freed in the branch 'VIR_APPEND_ELEMENT() < 0'. Use g_autoptr instead. Signed-off-by: Hao Wang Reviewed-by: Michal Privoznik --- diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index c54015336a..2f63772917 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1489,15 +1489,13 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt, goto cleanup; for (i = 0; i < naddresses; i++) { - virPCIDeviceAddressPtr addr = NULL; + g_autoptr(virPCIDeviceAddress) addr = NULL; if (VIR_ALLOC(addr) < 0) goto cleanup; - if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) { - VIR_FREE(addr); + if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) goto cleanup; - } if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions, pci_dev->num_virtual_functions,