Fix coverity CID #1455335 - Dereference after NULL check in fromdata_init()
authorShane Lontis <shane.lontis@oracle.com>
Tue, 11 Aug 2020 07:01:07 +0000 (17:01 +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/pmeth_gn.c

index 2f9346d9988ad4b6305b788aadb878ab472fd290..30968286789c2f8439debd85b742fc0c68e5ff84 100644 (file)
@@ -375,7 +375,8 @@ static int fromdata_init(EVP_PKEY_CTX *ctx, int operation)
     return 1;
 
  not_supported:
-    ctx->operation = EVP_PKEY_OP_UNDEFINED;
+    if (ctx != NULL)
+        ctx->operation = EVP_PKEY_OP_UNDEFINED;
     ERR_raise(ERR_LIB_EVP, EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE);
     return -2;
 }