mirror of https://github.com/openssl/openssl.git
dh: update to structure based atomics
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21260)
This commit is contained in:
parent
a22d1966bb
commit
9015cbb6eb
|
|
@ -78,7 +78,6 @@ static DH *dh_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx)
|
|||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
ret->references = 1;
|
||||
ret->lock = CRYPTO_THREAD_lock_new();
|
||||
if (ret->lock == NULL) {
|
||||
ERR_raise(ERR_LIB_DH, ERR_R_CRYPTO_LIB);
|
||||
|
|
@ -86,6 +85,9 @@ static DH *dh_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!CRYPTO_NEW_REF(&ret->references, 1))
|
||||
goto err;
|
||||
|
||||
ret->libctx = libctx;
|
||||
ret->meth = DH_get_default_method();
|
||||
#if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_ENGINE)
|
||||
|
|
@ -133,7 +135,7 @@ void DH_free(DH *r)
|
|||
if (r == NULL)
|
||||
return;
|
||||
|
||||
CRYPTO_DOWN_REF(&r->references, &i, r->lock);
|
||||
CRYPTO_DOWN_REF(&r->references, &i);
|
||||
REF_PRINT_COUNT("DH", r);
|
||||
if (i > 0)
|
||||
return;
|
||||
|
|
@ -149,6 +151,7 @@ void DH_free(DH *r)
|
|||
#endif
|
||||
|
||||
CRYPTO_THREAD_lock_free(r->lock);
|
||||
CRYPTO_FREE_REF(&r->references);
|
||||
|
||||
ossl_ffc_params_cleanup(&r->params);
|
||||
BN_clear_free(r->pub_key);
|
||||
|
|
@ -160,7 +163,7 @@ int DH_up_ref(DH *r)
|
|||
{
|
||||
int i;
|
||||
|
||||
if (CRYPTO_UP_REF(&r->references, &i, r->lock) <= 0)
|
||||
if (CRYPTO_UP_REF(&r->references, &i) <= 0)
|
||||
return 0;
|
||||
|
||||
REF_PRINT_COUNT("DH", r);
|
||||
|
|
|
|||
Loading…
Reference in New Issue