diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 6870ae7c40..d52d5e5c53 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -844,7 +844,8 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr meta, crypt_format = virReadBufInt32BE(buf + fileTypeInfo[meta->format].qcowCryptOffset); - if (crypt_format && VIR_ALLOC(meta->encryption) < 0) + if (crypt_format && !meta->encryption && + VIR_ALLOC(meta->encryption) < 0) goto cleanup; }