summaryrefslogtreecommitdiffstats
path: root/crypto/x509
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2023-06-22 01:45:45 +0200
committerPauli <pauli@openssl.org>2023-07-01 13:18:25 +0200
commita903a132a4256d34f20cb2f7636247b41fd85965 (patch)
tree9550b57a1373b747e58d446dd543cca048ec10b9 /crypto/x509
parentprov(legacy): update to structure based atomics (diff)
downloadopenssl-a903a132a4256d34f20cb2f7636247b41fd85965.tar.xz
openssl-a903a132a4256d34f20cb2f7636247b41fd85965.zip
x509: 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)
Diffstat (limited to 'crypto/x509')
-rw-r--r--crypto/x509/x509_lu.c10
-rw-r--r--crypto/x509/x509_set.c2
-rw-r--r--crypto/x509/x509cset.c2
3 files changed, 9 insertions, 5 deletions
diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c
index 247698583c..08b8425bbe 100644
--- a/crypto/x509/x509_lu.c
+++ b/crypto/x509/x509_lu.c
@@ -209,13 +209,16 @@ X509_STORE *X509_STORE_new(void)
ERR_raise(ERR_LIB_X509, ERR_R_CRYPTO_LIB);
goto err;
}
- ret->references = 1;
+
+ if (!CRYPTO_NEW_REF(&ret->references, 1))
+ goto err;
return ret;
err:
X509_VERIFY_PARAM_free(ret->param);
sk_X509_OBJECT_free(ret->objs);
sk_X509_LOOKUP_free(ret->get_cert_methods);
+ CRYPTO_THREAD_lock_free(ret->lock);
OPENSSL_free(ret);
return NULL;
}
@@ -228,7 +231,7 @@ void X509_STORE_free(X509_STORE *xs)
if (xs == NULL)
return;
- CRYPTO_DOWN_REF(&xs->references, &i, xs->lock);
+ CRYPTO_DOWN_REF(&xs->references, &i);
REF_PRINT_COUNT("X509_STORE", xs);
if (i > 0)
return;
@@ -246,6 +249,7 @@ void X509_STORE_free(X509_STORE *xs)
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE, xs, &xs->ex_data);
X509_VERIFY_PARAM_free(xs->param);
CRYPTO_THREAD_lock_free(xs->lock);
+ CRYPTO_FREE_REF(&xs->references);
OPENSSL_free(xs);
}
@@ -253,7 +257,7 @@ int X509_STORE_up_ref(X509_STORE *xs)
{
int i;
- if (CRYPTO_UP_REF(&xs->references, &i, xs->lock) <= 0)
+ if (CRYPTO_UP_REF(&xs->references, &i) <= 0)
return 0;
REF_PRINT_COUNT("X509_STORE", xs);
diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c
index 1d400a6b90..d4a6891829 100644
--- a/crypto/x509/x509_set.c
+++ b/crypto/x509/x509_set.c
@@ -116,7 +116,7 @@ int X509_up_ref(X509 *x)
{
int i;
- if (CRYPTO_UP_REF(&x->references, &i, x->lock) <= 0)
+ if (CRYPTO_UP_REF(&x->references, &i) <= 0)
return 0;
REF_PRINT_COUNT("X509", x);
diff --git a/crypto/x509/x509cset.c b/crypto/x509/x509cset.c
index 840b15c61c..3eec7d6412 100644
--- a/crypto/x509/x509cset.c
+++ b/crypto/x509/x509cset.c
@@ -75,7 +75,7 @@ int X509_CRL_up_ref(X509_CRL *crl)
{
int i;
- if (CRYPTO_UP_REF(&crl->references, &i, crl->lock) <= 0)
+ if (CRYPTO_UP_REF(&crl->references, &i) <= 0)
return 0;
REF_PRINT_COUNT("X509_CRL", crl);