virGetStorageVol can return NULL on out-of-memory. If it does, cleanly
abort the volume clone operation.
Signed-off-by: Michael Chapman <mike(a)very.puzzling.org>
---
src/storage/storage_driver.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index c83aa8a..2f7b2e5 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1828,6 +1828,10 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj,
pool->volumes.objs[pool->volumes.count++] = newvol;
volobj = virGetStorageVol(obj->conn, pool->def->name, newvol->name,
newvol->key, NULL, NULL);
+ if (!volobj) {
+ pool->volumes.count--;
+ goto cleanup;
+ }
/* Drop the pool lock during volume allocation */
pool->asyncjobs++;
--
1.8.3.1