diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2024-11-08 21:56:59 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2024-11-08 21:56:59 +0000 |
commit | b8ff11e994961bcce00ffc3f36ad8ceeb477dfcc (patch) | |
tree | 1c0de651551ca848c58b18d8f47226d1a357ffa7 /lib | |
parent | 5e0296c17474ec8c96ea860eb042ef878eb89dfe (diff) |
Clean up EC_KEY_free
r is a silly name for an EC_KEY and it is silly to assign the refcount
to a variable i (short for uninspired) when you can check the function
return directly. Tweak sizeof in freezero to jsing's liking.
ok beck jsing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/ec/ec_key.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/libcrypto/ec/ec_key.c b/lib/libcrypto/ec/ec_key.c index c8f4c15bb53..753ababa316 100644 --- a/lib/libcrypto/ec/ec_key.c +++ b/lib/libcrypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.43 2024/11/08 21:53:54 tb Exp $ */ +/* $OpenBSD: ec_key.c,v 1.44 2024/11/08 21:56:58 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -104,27 +104,24 @@ EC_KEY_new_by_curve_name(int nid) LCRYPTO_ALIAS(EC_KEY_new_by_curve_name); void -EC_KEY_free(EC_KEY *r) +EC_KEY_free(EC_KEY *ec_key) { - int i; - - if (r == NULL) + if (ec_key == NULL) return; - i = CRYPTO_add(&r->references, -1, CRYPTO_LOCK_EC); - if (i > 0) + if (CRYPTO_add(&ec_key->references, -1, CRYPTO_LOCK_EC) > 0) return; - if (r->meth != NULL && r->meth->finish != NULL) - r->meth->finish(r); + if (ec_key->meth != NULL && ec_key->meth->finish != NULL) + ec_key->meth->finish(ec_key); - CRYPTO_free_ex_data(CRYPTO_EX_INDEX_EC_KEY, r, &r->ex_data); + CRYPTO_free_ex_data(CRYPTO_EX_INDEX_EC_KEY, ec_key, &ec_key->ex_data); - EC_GROUP_free(r->group); - EC_POINT_free(r->pub_key); - BN_free(r->priv_key); + EC_GROUP_free(ec_key->group); + EC_POINT_free(ec_key->pub_key); + BN_free(ec_key->priv_key); - freezero(r, sizeof(EC_KEY)); + freezero(ec_key, sizeof(*ec_key)); } LCRYPTO_ALIAS(EC_KEY_free); |