Fix coverity CID #1454638 - Dereference after NULL check in EVP_MD_CTX_gettable_params()
authorShane Lontis <shane.lontis@oracle.com>
Tue, 11 Aug 2020 07:09:18 +0000 (17:09 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Mon, 24 Aug 2020 01:19:28 +0000 (11:19 +1000)
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/12628)

crypto/evp/digest.c

index 7caab8a5f78568212f302e6a981e7c467417498f..f5ec573828aba95a537a96ce05e1d38b453d8639 100644 (file)
@@ -671,8 +671,10 @@ const OSSL_PARAM *EVP_MD_CTX_gettable_params(EVP_MD_CTX *ctx)
 {
     EVP_PKEY_CTX *pctx;
 
-    if (ctx != NULL
-            && ctx->digest != NULL
+    if (ctx == NULL)
+        return NULL;
+
+    if (ctx->digest != NULL
             && ctx->digest->gettable_ctx_params != NULL)
         return ctx->digest->gettable_ctx_params(
                    ossl_provider_ctx(EVP_MD_provider(ctx->digest)));