mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
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.
This commit is contained in:
parent
14a961ca73
commit
bf130d2c85
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user