diff options
author | Pauli <ppzgs1@gmail.com> | 2021-03-19 09:40:05 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-03-26 08:46:02 +1000 |
commit | 40d6e05cf8075e1f37aeb5ea1b49f47896f951fa (patch) | |
tree | 1d7079d723b3d9dae19d0491bcd73bfa4ad58ba1 /crypto/evp/p_legacy.c | |
parent | 8cdcb63fc02239e92fc4bdcc5b97d38cc726c439 (diff) |
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14615)
Diffstat (limited to 'crypto/evp/p_legacy.c')
-rw-r--r-- | crypto/evp/p_legacy.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/crypto/evp/p_legacy.c b/crypto/evp/p_legacy.c index af93288dcb..c1d813f047 100644 --- a/crypto/evp/p_legacy.c +++ b/crypto/evp/p_legacy.c @@ -57,11 +57,13 @@ RSA *EVP_PKEY_get1_RSA(EVP_PKEY *pkey) #ifndef OPENSSL_NO_EC int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, EC_KEY *key) { - int ret = EVP_PKEY_assign_EC_KEY(pkey, key); - - if (ret) - EC_KEY_up_ref(key); - return ret; + if (!EC_KEY_up_ref(key)) + return 0; + if (!EVP_PKEY_assign_EC_KEY(pkey, key)) { + EC_KEY_free(key); + return 0; + } + return 1; } EC_KEY *evp_pkey_get0_EC_KEY_int(const EVP_PKEY *pkey) @@ -82,8 +84,8 @@ EC_KEY *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey) { EC_KEY *ret = evp_pkey_get0_EC_KEY_int(pkey); - if (ret != NULL) - EC_KEY_up_ref(ret); + if (ret != NULL && !EC_KEY_up_ref(ret)) + ret = NULL; return ret; } #endif /* OPENSSL_NO_EC */ |