提交 bf130d2c 编写于 作者: M Matthias Bolte

Fix small memory leaks in config parsing related functions

Found by 'make -C tests valgrind'.

xen_xm.c: Dummy allocation via virDomainChrDefNew is directly
overwritten and lost. Free 'script' in success path too.

vmx.c: Free virtualDev_string in success path too.

domain_conf.c: Free compression in success path too.
上级 14a961ca
......@@ -4058,6 +4058,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
VIR_FREE(compression);
goto error;
}
VIR_FREE(compression);
def->data.spice.zlib = compressionVal;
} else if (xmlStrEqual(cur->name, BAD_CAST "playback")) {
......
......@@ -1818,6 +1818,7 @@ int
virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
int *virtualDev)
{
int result = -1;
char present_name[32];
char virtualDev_name[32];
char *virtualDev_string = NULL;
......@@ -1840,16 +1841,17 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
controller);
if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0) {
goto failure;
goto cleanup;
}
if (! *present) {
return 0;
result = 0;
goto cleanup;
}
if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev_string,
true) < 0) {
goto failure;
goto cleanup;
}
if (virtualDev_string != NULL) {
......@@ -1870,16 +1872,16 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
_("Expecting VMX entry '%s' to be 'buslogic' or 'lsilogic' "
"or 'lsisas1068' or 'pvscsi' but found '%s'"),
virtualDev_name, virtualDev_string);
goto failure;
goto cleanup;
}
}
return 0;
result = 0;
failure:
cleanup:
VIR_FREE(virtualDev_string);
return -1;
return result;
}
......
......@@ -983,8 +983,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
continue;
}
if (!(chr = virDomainChrDefNew()))
goto cleanup;
if (!(chr = xenParseSxprChar(port, NULL)))
goto cleanup;
......@@ -1034,6 +1032,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
goto cleanup;
}
VIR_FREE(script);
return def;
no_memory:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册