From 3ee5a4ddf717cf8438a6b3c359bf6be48fd6bee7 Mon Sep 17 00:00:00 2001 From: Chen Hanxiao Date: Sat, 17 Mar 2018 18:24:09 +0800 Subject: [PATCH] qemu: fix a mem leak fix a mem leak Signed-off-by: Chen Hanxiao Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 5c55c69aff..7bcc4936de 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20667,15 +20667,15 @@ qemuARPGetInterfaces(virDomainObjPtr vm, if (VIR_ALLOC(iface) < 0) goto cleanup; - iface->naddrs = 1; if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0) goto cleanup; if (VIR_STRDUP(iface->hwaddr, macaddr) < 0) goto cleanup; - if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) + if (VIR_ALLOC(iface->addrs) < 0) goto cleanup; + iface->naddrs = 1; if (VIR_STRDUP(iface->addrs->addr, entry.ipaddr) < 0) goto cleanup; @@ -20691,6 +20691,7 @@ qemuARPGetInterfaces(virDomainObjPtr vm, cleanup: virArpTableFree(table); + virDomainInterfaceFree(iface); if (ifaces_ret) { for (i = 0; i < ifaces_count; i++)