提交 2f7ced36 编写于 作者: J John Ferlan

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
上级 2cc03c80
......@@ -2108,6 +2108,7 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
virCapsGuestMachinePtr mach;
if (VIR_ALLOC(mach) < 0)
goto error;
(*machines)[i] = mach;
if (qemuCaps->machineAliases[i]) {
if (VIR_STRDUP(mach->name, qemuCaps->machineAliases[i]) < 0 ||
VIR_STRDUP(mach->canonical, qemuCaps->machineTypes[i]) < 0)
......@@ -2117,7 +2118,6 @@ int virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps,
goto error;
}
mach->maxCpus = qemuCaps->machineMaxCpus[i];
(*machines)[i] = mach;
}
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册