]> 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:49:47 +0000 (07:49 +0100)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17225)

(cherry picked from commit d580c2790f9f304533a3eda2a9cf6b8eb22830c3)

crypto/cmp/cmp_msg.c

index 10ef4cd922ec591663401fd57e4a8ef70c042227..84a272fe2b062e7b994f41d3b057de3dae1b2c0d 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;
     }