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:
Pavel Hrdina 2017-04-09 12:49:24 +02:00
parent 87d97a9d0a
commit ffc810b7c7
3 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

@ -471,6 +471,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
port);
goto cleanup;
}
VIR_FREE(port);
}
}
}

View File

@ -521,6 +521,8 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret)
&processor->processor_family,
'=', '\n'))
goto cleanup;
VIR_FREE(procline);
}
result = 0;