if (method->create != NULL && !method->create(bio)) {
ERR_raise(ERR_LIB_BIO, ERR_R_INIT_FAIL);
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, bio, &bio->ex_data);
- CRYPTO_FREE_REF(&bio->references);
goto err;
}
if (method->create == NULL)
return NULL;
}
- if (!CRYPTO_NEW_REF(&ret->references, 1))
- goto err;
+ if (!CRYPTO_NEW_REF(&ret->references, 1)) {
+ CRYPTO_THREAD_lock_free(ret->lock);
+ OPENSSL_free(ret);
+ return NULL;
+ }
ret->libctx = libctx;
ret->meth = DH_get_default_method();
return NULL;
}
- if (!CRYPTO_NEW_REF(&ret->references, 1))
- goto err;
+ if (!CRYPTO_NEW_REF(&ret->references, 1)) {
+ CRYPTO_THREAD_lock_free(ret->lock);
+ OPENSSL_free(ret);
+ return NULL;
+ }
ret->libctx = libctx;
ret->meth = DSA_get_default_method();
if (ret == NULL)
return NULL;
+ if (!CRYPTO_NEW_REF(&ret->references, 1)) {
+ OPENSSL_free(ret);
+ return NULL;
+ }
+
ret->libctx = libctx;
if (propq != NULL) {
ret->propq = OPENSSL_strdup(propq);
goto err;
}
- if (!CRYPTO_NEW_REF(&ret->references, 1))
- goto err;
-
ret->meth = EC_KEY_get_default_method();
#if !defined(OPENSSL_NO_ENGINE) && !defined(FIPS_MODULE)
if (engine != NULL) {
return ret;
err:
- CRYPTO_FREE_REF(&ret->references);
EC_KEY_free(ret);
return NULL;
}
{
EVP_RAND *rand = OPENSSL_zalloc(sizeof(*rand));
- if (rand == NULL || !CRYPTO_NEW_REF(&rand->refcnt, 1)) {
+ if (rand == NULL)
+ return NULL;
+
+ if (!CRYPTO_NEW_REF(&rand->refcnt, 1)) {
OPENSSL_free(rand);
return NULL;
}
if ((prov = OPENSSL_zalloc(sizeof(*prov))) == NULL)
return NULL;
if (!CRYPTO_NEW_REF(&prov->refcnt, 1)) {
- ossl_provider_free(prov);
+ OPENSSL_free(prov);
return NULL;
}
#ifndef HAVE_ATOMICS
return NULL;
}
- if (!CRYPTO_NEW_REF(&ret->references, 1))
- goto err;
+ if (!CRYPTO_NEW_REF(&ret->references, 1)) {
+ CRYPTO_THREAD_lock_free(ret->lock);
+ OPENSSL_free(ret);
+ return NULL;
+ }
ret->libctx = libctx;
ret->meth = RSA_get_default_method();
static ossl_unused ossl_inline void CRYPTO_FREE_REF(CRYPTO_REF_COUNT *refcnt) \
{
- CRYPTO_THREAD_lock_free(refcnt->lock);
+ if (refcnt != NULL)
+ CRYPTO_THREAD_lock_free(refcnt->lock);
}
# else /* OPENSSL_THREADS */
if (!OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL))
return NULL;
+ /* Doing this for the run once effect */
if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) {
ERR_raise(ERR_LIB_SSL, SSL_R_X509_VERIFICATION_SETUP_PROBLEMS);
goto err;
ret = OPENSSL_zalloc(sizeof(*ret));
if (ret == NULL)
- goto err;
+ return NULL;
/* Init the reference counting before any call to SSL_CTX_free */
- if (!CRYPTO_NEW_REF(&ret->references, 1))
- goto err;
+ if (!CRYPTO_NEW_REF(&ret->references, 1)) {
+ OPENSSL_free(ret);
+ return NULL;
+ }
ret->lock = CRYPTO_THREAD_lock_new();
if (ret->lock == NULL) {
SSL_SESSION *dest;
dest = OPENSSL_malloc(sizeof(*dest));
- if (dest == NULL) {
- goto err;
- }
+ if (dest == NULL)
+ return NULL;
memcpy(dest, src, sizeof(*dest));
/*
dest->next = NULL;
dest->owner = NULL;
- if (!CRYPTO_NEW_REF(&dest->references, 1))
- goto err;
+ if (!CRYPTO_NEW_REF(&dest->references, 1)) {
+ OPENSSL_free(dest);
+ return NULL;
+ }
if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL_SESSION, dest, &dest->ex_data)) {
ERR_raise(ERR_LIB_SSL, ERR_R_CRYPTO_LIB);