diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index b2617734507b7f6571da0601d34e60a5d5769721..2b6011ba3cdcf4cd003334d4f9d09902841be4cc 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -57,7 +57,8 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr pool, */ tmp = strrchr(groups[0], '/'); if (VIR_STRDUP(vol->name, tmp ? tmp + 1 : groups[0]) < 0 || - VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count, vol) < 0) { + VIR_APPEND_ELEMENT_COPY(pool->volumes.objs, + pool->volumes.count, vol) < 0) { virStorageVolDefFree(vol); return -1; } diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index bc52474b26d302c2254f7f77a02f4c66e7082f58..d78dbe4d30cbd1015e196862862b299273c68375 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -401,6 +401,7 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn, } if (VIR_APPEND_ELEMENT(pool->volumes.objs, pool->volumes.count, vol) < 0) { + virStorageVolDefFree(vol); virStoragePoolObjClearVols(pool); goto cleanup; }