goto cleanup;
}
snapshot = virVBoxSnapshotConfSnapshotByName(machine->snapshot, snapshotName);
+ if (snapshot == NULL) {
+ virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT,
+ _("Unable to find the snapshot %s"), snapshotName);
+ goto cleanup;
+ }
return STREQ(snapshot->uuid, machine->currentSnapshot);
cleanup:
{
int result = -1;
size_t i = 0;
- char **ret;
+ char **ret = NULL;
xmlDocPtr xml = NULL;
xmlXPathContextPtr xPathContext = NULL;
xmlNodePtr *nodes = NULL;
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;
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;
}
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;
if (result < 0) {
virStringFreeList(ret);
nodeSize = -1;
+ } else {
+ *roDisksPath = ret;
}
- *roDisksPath = ret;
+ VIR_FREE(nodes);
return nodeSize;
}