mirror of https://gitee.com/openkylin/libvirt.git
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>
This commit is contained in:
parent
87d97a9d0a
commit
ffc810b7c7
|
@ -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…
Reference in New Issue