From: Pauli Date: Sun, 26 Apr 2020 22:42:20 +0000 (+1000) Subject: coverity 1462554 Dereference after null check X-Git-Tag: openssl-3.0.0-alpha2~124 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9dbfb11d5a204badbc28dec27cb98121bb00f996;p=oweals%2Fopenssl.git coverity 1462554 Dereference after null check Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/11651) --- diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 053c9cb557..bbeb7276fe 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -1212,10 +1212,12 @@ static int pkey_set_type(EVP_PKEY *pkey, ENGINE *e, int type, const char *str, * to the |save_type| field, because |type| is supposed to be set * to EVP_PKEY_NONE in that case. */ - if (keymgmt != NULL) - pkey->save_type = ameth->pkey_id; - else if (pkey->ameth != NULL) - pkey->type = ameth->pkey_id; + if (ameth != NULL) { + if (keymgmt != NULL) + pkey->save_type = ameth->pkey_id; + else if (pkey->ameth != NULL) + pkey->type = ameth->pkey_id; + } #endif } return 1;