diff options
Diffstat (limited to 'deps/openssl/openssl/crypto/engine/eng_lib.c')
-rw-r--r-- | deps/openssl/openssl/crypto/engine/eng_lib.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/deps/openssl/openssl/crypto/engine/eng_lib.c b/deps/openssl/openssl/crypto/engine/eng_lib.c index ef8e995503..3ef3aae28a 100644 --- a/deps/openssl/openssl/crypto/engine/eng_lib.c +++ b/deps/openssl/openssl/crypto/engine/eng_lib.c @@ -7,8 +7,10 @@ * https://www.openssl.org/source/license.html */ +#include "e_os.h" #include "eng_int.h" #include <openssl/rand.h> +#include "internal/refcount.h" CRYPTO_RWLOCK *global_engine_lock; @@ -67,17 +69,17 @@ void engine_set_all_null(ENGINE *e) e->flags = 0; } -int engine_free_util(ENGINE *e, int locked) +int engine_free_util(ENGINE *e, int not_locked) { int i; if (e == NULL) return 1; - if (locked) - CRYPTO_atomic_add(&e->struct_ref, -1, &i, global_engine_lock); + if (not_locked) + CRYPTO_DOWN_REF(&e->struct_ref, &i, global_engine_lock); else i = --e->struct_ref; - engine_ref_debug(e, 0, -1) + engine_ref_debug(e, 0, -1); if (i > 0) return 1; REF_ASSERT_ISNT(i < 0); @@ -121,9 +123,12 @@ static int int_cleanup_check(int create) static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb) { - ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item)); - if (item == NULL) + ENGINE_CLEANUP_ITEM *item; + + if ((item = OPENSSL_malloc(sizeof(*item))) == NULL) { + ENGINEerr(ENGINE_F_INT_CLEANUP_ITEM, ERR_R_MALLOC_FAILURE); return NULL; + } item->cb = cb; return item; } @@ -131,6 +136,7 @@ static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb) void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb) { ENGINE_CLEANUP_ITEM *item; + if (!int_cleanup_check(1)) return; item = int_cleanup_item(cb); @@ -171,12 +177,12 @@ void engine_cleanup_int(void) int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg) { - return (CRYPTO_set_ex_data(&e->ex_data, idx, arg)); + return CRYPTO_set_ex_data(&e->ex_data, idx, arg); } void *ENGINE_get_ex_data(const ENGINE *e, int idx) { - return (CRYPTO_get_ex_data(&e->ex_data, idx)); + return CRYPTO_get_ex_data(&e->ex_data, idx); } /* |