Clean up some Coverity warnings from commit id '4dc5d8f1'
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/vbox/vbox_snapshot_conf.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c
index 9c78410..676a0e1 100644
--- a/src/vbox/vbox_snapshot_conf.c
+++ b/src/vbox/vbox_snapshot_conf.c
@@ -1257,6 +1257,11 @@ virVBoxSnapshotConfIsCurrentSnapshot(virVBoxSnapshotConfMachinePtr
machine,
goto cleanup;
}
snapshot = virVBoxSnapshotConfSnapshotByName(machine->snapshot, snapshotName);
+ if (snapshot == NULL) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to find the snapshot %s"), snapshotName);
+ goto cleanup;
+ }
return STREQ(snapshot->uuid, machine->currentSnapshot);
cleanup:
@@ -1274,7 +1279,7 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char
*filePath,
{
int result = -1;
size_t i = 0;
- char **ret;
+ char **ret = NULL;
xmlDocPtr xml = NULL;
xmlXPathContextPtr xPathContext = NULL;
xmlNodePtr *nodes = NULL;
@@ -1296,7 +1301,9 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char
*filePath,
goto cleanup;
}
xPathContext->node = xmlDocGetRootElement(xml);
- nodeSize = virXPathNodeSet("/domainsnapshot/disks/disk", xPathContext,
&nodes);
+ if ((nodeSize = virXPathNodeSet("/domainsnapshot/disks/disk",
+ xPathContext, &nodes)) < 0)
+ goto cleanup;
if (VIR_ALLOC_N(ret, nodeSize) < 0)
goto cleanup;
@@ -1315,13 +1322,12 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char
*filePath,
xmlFreeDoc(xml);
xmlXPathFreeContext(xPathContext);
if (result < 0) {
- for (i = 0; i < nodeSize; i++)
- VIR_FREE(ret[i]);
- VIR_FREE(ret);
+ virStringFreeList(ret);
nodeSize = -1;
} else {
*rwDisksPath = ret;
}
+ VIR_FREE(nodes);
return nodeSize;
}
@@ -1357,9 +1363,10 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char
*filePath,
goto cleanup;
}
xPathContext->node = xmlDocGetRootElement(xml);
- nodeSize = virXPathNodeSet("/domainsnapshot/domain/devices/disk",
- xPathContext,
- &nodes);
+ if ((nodeSize = virXPathNodeSet("/domainsnapshot/domain/devices/disk",
+ xPathContext,
+ &nodes)) < 0)
+ goto cleanup;
if (VIR_ALLOC_N(ret, nodeSize) < 0)
goto cleanup;
@@ -1379,8 +1386,10 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char
*filePath,
if (result < 0) {
virStringFreeList(ret);
nodeSize = -1;
+ } else {
+ *roDisksPath = ret;
}
- *roDisksPath = ret;
+ VIR_FREE(nodes);
return nodeSize;
}
--
1.9.3