summaryrefslogtreecommitdiffstats
path: root/crypto/x509/x509_set.c
diff options
context:
space:
mode:
authorFdaSilvaYY <fdasilvayy@gmail.com>2016-03-07 22:45:58 +0100
committerMatt Caswell <matt@openssl.org>2016-05-16 10:17:33 +0100
commitc5ebfcab713a82a1d46a51c8c2668c419425b387 (patch)
treeca8da99a90b24c37c37ce417ad02c1f35e1e1735 /crypto/x509/x509_set.c
parent592b6fb489c97be2b039ab671647aa58a472204a (diff)
Unify <TYPE>_up_ref methods signature and behaviour.
Add a status return value instead of void. Add some sanity checks on reference counter value. Update the docs. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'crypto/x509/x509_set.c')
-rw-r--r--crypto/x509/x509_set.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c
index 360ead87d3..59a6b29f89 100644
--- a/crypto/x509/x509_set.c
+++ b/crypto/x509/x509_set.c
@@ -146,10 +146,16 @@ int X509_set_pubkey(X509 *x, EVP_PKEY *pkey)
return (X509_PUBKEY_set(&(x->cert_info.key), pkey));
}
-void X509_up_ref(X509 *x)
+int X509_up_ref(X509 *x)
{
int i;
- CRYPTO_atomic_add(&x->references, 1, &i, x->lock);
+
+ if (CRYPTO_atomic_add(&x->references, 1, &i, x->lock) <= 0)
+ return 0;
+
+ REF_PRINT_COUNT("X509", x);
+ REF_ASSERT_ISNT(i < 2);
+ return ((i > 1) ? 1 : 0);
}
long X509_get_version(X509 *x)