]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
avoid a NULL dereference when getting digest
authorPauli <pauli@openssl.org>
Wed, 3 Nov 2021 22:23:32 +0000 (08:23 +1000)
committerDr. Matthias St. Pierre <matthias.st.pierre@ncp-e.com>
Sun, 7 Nov 2021 21:01:38 +0000 (22:01 +0100)
Fixes #16961

Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/16969)

crypto/evp/evp_lib.c

index 64d7fb046de9c75d1f72ab0f01f6b0c8da89bbfb..24092cfd5be0599ca3fa12994125431ee560cfdc 100644 (file)
@@ -999,7 +999,7 @@ EVP_MD *EVP_MD_CTX_get1_md(EVP_MD_CTX *ctx)
     if (ctx == NULL)
         return NULL;
     md = (EVP_MD *)ctx->reqdigest;
-    if (!EVP_MD_up_ref(md))
+    if (md == NULL || !EVP_MD_up_ref(md))
         return NULL;
     return md;
 }