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

qemu: Resolve Coverity RESOURCE_LEAK

Recent changes to the -M/--machine processing code in qemuParseCommandLine
caused Coverity to determine there was a possible resource leak with how
the 'list' is managed. Rather than try to add virStringFreeList calls
everywhere - just promote list to the top of the variables and free it
within the error processing code. Also required a couple of other tweaks
in order to avoid double free's.
上级 c214f56a
...@@ -12412,6 +12412,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, ...@@ -12412,6 +12412,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
size_t i; size_t i;
bool nographics = false; bool nographics = false;
bool fullscreen = false; bool fullscreen = false;
char **list = NULL;
char *path; char *path;
size_t nnics = 0; size_t nnics = 0;
const char **nics = NULL; const char **nics = NULL;
...@@ -12879,7 +12880,6 @@ qemuParseCommandLine(virCapsPtr qemuCaps, ...@@ -12879,7 +12880,6 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
VIR_FREE(def->name); VIR_FREE(def->name);
} else if (STREQ(arg, "-M") || } else if (STREQ(arg, "-M") ||
STREQ(arg, "-machine")) { STREQ(arg, "-machine")) {
char **list;
char *param; char *param;
size_t j = 0; size_t j = 0;
...@@ -12894,10 +12894,8 @@ qemuParseCommandLine(virCapsPtr qemuCaps, ...@@ -12894,10 +12894,8 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
if (STRPREFIX(param, "type=")) if (STRPREFIX(param, "type="))
param += strlen("type="); param += strlen("type=");
if (!strchr(param, '=')) { if (!strchr(param, '=')) {
if (VIR_STRDUP(def->os.machine, param) < 0) { if (VIR_STRDUP(def->os.machine, param) < 0)
virStringFreeList(list);
goto error; goto error;
}
j++; j++;
} }
...@@ -12942,6 +12940,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, ...@@ -12942,6 +12940,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
} }
} }
virStringFreeList(list); virStringFreeList(list);
list = NULL;
} else if (STREQ(arg, "-serial")) { } else if (STREQ(arg, "-serial")) {
WANT_VALUE(); WANT_VALUE();
if (STRNEQ(val, "none")) { if (STRNEQ(val, "none")) {
...@@ -13415,6 +13414,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, ...@@ -13415,6 +13414,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
virDomainDiskDefFree(disk); virDomainDiskDefFree(disk);
qemuDomainCmdlineDefFree(cmd); qemuDomainCmdlineDefFree(cmd);
virDomainDefFree(def); virDomainDefFree(def);
virStringFreeList(list);
VIR_FREE(nics); VIR_FREE(nics);
if (monConfig) { if (monConfig) {
virDomainChrSourceDefFree(*monConfig); virDomainChrSourceDefFree(*monConfig);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册