mirror of https://gitee.com/openkylin/libvirt.git
qemu_capabilities: Resolve Coverity RESOURCE_LEAK
Coverity determined that on error path that 'mach' wouldn't be free'd Since virCapabilitiesFreeGuestMachine() isn't globally available, we'll insert first and then if the VIR_STRDUP's fail they it will eventually cause the 'mach' to be freed in the error path
This commit is contained in:
parent
2cc03c8050
commit
2f7ced36e6
|
@ -2108,6 +2108,7 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
|
||||||
virCapsGuestMachinePtr mach;
|
virCapsGuestMachinePtr mach;
|
||||||
if (VIR_ALLOC(mach) < 0)
|
if (VIR_ALLOC(mach) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
(*machines)[i] = mach;
|
||||||
if (qemuCaps->machineAliases[i]) {
|
if (qemuCaps->machineAliases[i]) {
|
||||||
if (VIR_STRDUP(mach->name, qemuCaps->machineAliases[i]) < 0 ||
|
if (VIR_STRDUP(mach->name, qemuCaps->machineAliases[i]) < 0 ||
|
||||||
VIR_STRDUP(mach->canonical, qemuCaps->machineTypes[i]) < 0)
|
VIR_STRDUP(mach->canonical, qemuCaps->machineTypes[i]) < 0)
|
||||||
|
@ -2117,7 +2118,6 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
mach->maxCpus = qemuCaps->machineMaxCpus[i];
|
mach->maxCpus = qemuCaps->machineMaxCpus[i];
|
||||||
(*machines)[i] = mach;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue