mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-13 16:15:19 +00:00
src: fix multiple resource leaks in loops
All of the variables are filled inside a loop and therefore needs to be also freed in every cycle. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> (cherry picked from commit ffc810b7c7cad514fe362c5b42877bca7eee88b3)
This commit is contained in:
parent
fdd08607c2
commit
c714afcc99
@ -1582,7 +1582,6 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
|
||||
for (i = 0, m = 0; i < n; i++) {
|
||||
xmlNodePtr node = nodes[i];
|
||||
char *tmp = virXMLPropString(node, "type");
|
||||
virNodeDevDevnodeType type;
|
||||
int val;
|
||||
|
||||
if (!tmp) {
|
||||
@ -1591,15 +1590,17 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((val = virNodeDevDevnodeTypeFromString(tmp)) < 0) {
|
||||
val = virNodeDevDevnodeTypeFromString(tmp);
|
||||
|
||||
if (val < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown devnode type '%s'"), tmp);
|
||||
VIR_FREE(tmp);
|
||||
goto error;
|
||||
}
|
||||
type = val;
|
||||
VIR_FREE(tmp);
|
||||
|
||||
switch (type) {
|
||||
switch ((virNodeDevDevnodeType)val) {
|
||||
case VIR_NODE_DEV_DEVNODE_DEV:
|
||||
def->devnode = (char*)xmlNodeGetContent(node);
|
||||
break;
|
||||
|
@ -471,6 +471,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
|
||||
port);
|
||||
goto cleanup;
|
||||
}
|
||||
VIR_FREE(port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -521,6 +521,8 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
|
||||
&processor->processor_family,
|
||||
'=', '\n'))
|
||||
goto cleanup;
|
||||
|
||||
VIR_FREE(procline);
|
||||
}
|
||||
result = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user