diff options
-rw-r--r-- | crypto/dsa/dsa_lib.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index bcfd467b1c..03c4cb0c06 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -137,7 +137,6 @@ static DSA *dsa_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_DSA, ERR_R_CRYPTO_LIB); @@ -145,6 +144,9 @@ static DSA *dsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx) return NULL; } + if (!CRYPTO_NEW_REF(&ret->references, 1)) + goto err; + ret->libctx = libctx; ret->meth = DSA_get_default_method(); #if !defined(FIPS_MODULE) && !defined(OPENSSL_NO_ENGINE) @@ -210,7 +212,7 @@ void DSA_free(DSA *r) if (r == NULL) return; - CRYPTO_DOWN_REF(&r->references, &i, r->lock); + CRYPTO_DOWN_REF(&r->references, &i); REF_PRINT_COUNT("DSA", r); if (i > 0) return; @@ -227,6 +229,7 @@ void DSA_free(DSA *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); @@ -238,7 +241,7 @@ int DSA_up_ref(DSA *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("DSA", r); |