mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 03:21:44 +03:00
qemu_capabilities: Resolve Coverity RESOURCE_LEAK
In function virQEMUCapsParseMachineTypesStr, VIR_STRNDUP allocates memory for 'name' in {do,while} loop. If 'name' isn't freed before 'continue', its memory will be allocated again in the next loop. In this case the memory allocated for 'name' in privious loop is useless and not freed. Free it before continue this loop to fix that. Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
This commit is contained in:
parent
64cef432aa
commit
6781d5b5a8
@ -433,8 +433,10 @@ virQEMUCapsParseMachineTypesStr(const char *output,
|
||||
|
||||
if ((t = strstr(p, "(alias of ")) && (!next || t < next)) {
|
||||
p = t + strlen("(alias of ");
|
||||
if (!(t = strchr(p, ')')) || (next && t >= next))
|
||||
if (!(t = strchr(p, ')')) || (next && t >= next)) {
|
||||
VIR_FREE(name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (VIR_STRNDUP(canonical, p, t - p) < 0) {
|
||||
VIR_FREE(name);
|
||||
|
Loading…
Reference in New Issue
Block a user