mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-21 10:50:24 +03:00
qemu: don't leak in qemuGetDHCPInterfaces when failing to alloc
We forgot to free alloced mem when failed to dup ifname or macaddr. Also use VIR_STEAL_PTR to simplify codes. Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a90a1bf9e1
commit
60a95e5242
@ -2190,8 +2190,7 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
|
||||
iface->naddrs = addrs_count;
|
||||
}
|
||||
|
||||
*ifaces = ifaces_ret;
|
||||
ifaces_ret = NULL;
|
||||
VIR_STEAL_PTR(*ifaces, ifaces_ret);
|
||||
ret = ifaces_count;
|
||||
|
||||
cleanup:
|
||||
|
@ -20569,10 +20569,10 @@ qemuGetDHCPInterfaces(virDomainPtr dom,
|
||||
goto error;
|
||||
|
||||
if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0)
|
||||
goto cleanup;
|
||||
goto error;
|
||||
|
||||
if (VIR_STRDUP(iface->hwaddr, macaddr) < 0)
|
||||
goto cleanup;
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (j = 0; j < n_leases; j++) {
|
||||
@ -20580,7 +20580,7 @@ qemuGetDHCPInterfaces(virDomainPtr dom,
|
||||
virDomainIPAddressPtr ip_addr = &iface->addrs[j];
|
||||
|
||||
if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0)
|
||||
goto cleanup;
|
||||
goto error;
|
||||
|
||||
ip_addr->type = lease->type;
|
||||
ip_addr->prefix = lease->prefix;
|
||||
@ -20592,8 +20592,7 @@ qemuGetDHCPInterfaces(virDomainPtr dom,
|
||||
VIR_FREE(leases);
|
||||
}
|
||||
|
||||
*ifaces = ifaces_ret;
|
||||
ifaces_ret = NULL;
|
||||
VIR_STEAL_PTR(*ifaces, ifaces_ret);
|
||||
rv = ifaces_count;
|
||||
|
||||
cleanup:
|
||||
|
Loading…
x
Reference in New Issue
Block a user