diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c9b6187fc7..770c00bbb3 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -848,7 +848,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; }