提交 6781d5b5 编写于 作者: W Wang Rui 提交者: Ján Tomko

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: NWang Rui <moon.wangrui@huawei.com>
上级 64cef432
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册