diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-04-19 15:50:35 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-04-22 16:46:20 +0200 |
commit | db6b1266ab30945de2d14fbc62e9c3c308cce897 (patch) | |
tree | 8624d986df1c5f28391e74490101c021a5c81291 /crypto/ec | |
parent | Removed dead code in linebuffer_ctrl() (diff) | |
download | openssl-db6b1266ab30945de2d14fbc62e9c3c308cce897.tar.xz openssl-db6b1266ab30945de2d14fbc62e9c3c308cce897.zip |
Fix potential NULL dereference in ossl_ec_key_dup()
Fixes Coverity ID 1476282
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14928)
Diffstat (limited to 'crypto/ec')
-rw-r--r-- | crypto/ec/ec_backend.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crypto/ec/ec_backend.c b/crypto/ec/ec_backend.c index e9843eb4ac..581c006fd0 100644 --- a/crypto/ec/ec_backend.c +++ b/crypto/ec/ec_backend.c @@ -532,17 +532,17 @@ int ossl_ec_key_is_foreign(const EC_KEY *ec) EC_KEY *ossl_ec_key_dup(const EC_KEY *src, int selection) { - EC_KEY *ret = ossl_ec_key_new_method_int(src->libctx, src->propq, - src->engine); - - if (ret == NULL) - return NULL; + EC_KEY *ret; if (src == NULL) { ERR_raise(ERR_LIB_EC, ERR_R_PASSED_NULL_PARAMETER); - goto err; + return NULL; } + if ((ret = ossl_ec_key_new_method_int(src->libctx, src->propq, + src->engine)) == NULL) + return NULL; + /* copy the parameters */ if (src->group != NULL && (selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) { |