diff options
author | FdaSilvaYY <fdasilvayy@gmail.com> | 2016-03-07 22:45:58 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-05-16 10:17:33 +0100 |
commit | c5ebfcab713a82a1d46a51c8c2668c419425b387 (patch) | |
tree | ca8da99a90b24c37c37ce417ad02c1f35e1e1735 /crypto/evp | |
parent | 592b6fb489c97be2b039ab671647aa58a472204a (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/evp')
-rw-r--r-- | crypto/evp/p_lib.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index a8fa301b31..94b311fa90 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -196,10 +196,16 @@ EVP_PKEY *EVP_PKEY_new(void) return ret; } -void EVP_PKEY_up_ref(EVP_PKEY *pkey) +int EVP_PKEY_up_ref(EVP_PKEY *pkey) { int i; - CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock); + + if (CRYPTO_atomic_add(&pkey->references, 1, &i, pkey->lock) <= 0) + return 0; + + REF_PRINT_COUNT("EVP_PKEY", pkey); + REF_ASSERT_ISNT(i < 2); + return ((i > 1) ? 1 : 0); } /* |