From: Dr. David von Oheimb Date: Tue, 7 Dec 2021 16:49:05 +0000 (+0100) Subject: OSSL_CMP_MSG_read(): Fix mem leak on file read error X-Git-Tag: openssl-3.2.0-alpha1~3242 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d580c2790f9f304533a3eda2a9cf6b8eb22830c3;p=thirdparty%2Fopenssl.git OSSL_CMP_MSG_read(): Fix mem leak on file read error Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/17225) --- diff --git a/crypto/cmp/cmp_msg.c b/crypto/cmp/cmp_msg.c index 51b0998bdcc..0497155e093 100644 --- a/crypto/cmp/cmp_msg.c +++ b/crypto/cmp/cmp_msg.c @@ -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; }