OSSL_CMP_MSG_read(): Fix mem leak on file read error

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17225)
This commit is contained in:
Dr. David von Oheimb 2021-12-07 17:49:05 +01:00 committed by Dr. David von Oheimb
parent f5485b97b6
commit d580c2790f

View File

@ -1100,9 +1100,8 @@ OSSL_CMP_MSG *OSSL_CMP_MSG_read(const char *file, OSSL_LIB_CTX *libctx,
return NULL;
}
if ((bio = BIO_new_file(file, "rb")) == NULL)
return NULL;
if (d2i_OSSL_CMP_MSG_bio(bio, &msg) == NULL) {
if ((bio = BIO_new_file(file, "rb")) == NULL
|| d2i_OSSL_CMP_MSG_bio(bio, &msg) == NULL) {
OSSL_CMP_MSG_free(msg);
msg = NULL;
}