]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
OSSL_CMP_MSG_read(): Fix mem leak on file read error
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Tue, 7 Dec 2021 16:49:05 +0000 (17:49 +0100)
committerDr. David von Oheimb <dev@ddvo.net>
Thu, 9 Dec 2021 06:44:29 +0000 (07:44 +0100)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17225)

crypto/cmp/cmp_msg.c

index 51b0998bdccea16c9790f803b1c03fb50ff70502..0497155e0936ccac28b89828f14b7f4edd071de3 100644 (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;
     }