projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update copyright year
[openssl.git]
/
crypto
/
engine
/
eng_lib.c
diff --git
a/crypto/engine/eng_lib.c
b/crypto/engine/eng_lib.c
index a500992a21857c0c2d8d0fdeb2a06ef72f883512..d7f2026fac546cb143a319e1cab7afd138d920ae 100644
(file)
--- a/
crypto/engine/eng_lib.c
+++ b/
crypto/engine/eng_lib.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 2001-201
6
The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2001-201
9
The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@
-20,8
+20,9
@@
CRYPTO_ONCE engine_lock_init = CRYPTO_ONCE_STATIC_INIT;
DEFINE_RUN_ONCE(do_engine_lock_init)
{
DEFINE_RUN_ONCE(do_engine_lock_init)
{
- OPENSSL_init_crypto(0, NULL);
- global_engine_lock = CRYPTO_THREAD_glock_new("global_engine");
+ if (!OPENSSL_init_crypto(0, NULL))
+ return 0;
+ global_engine_lock = CRYPTO_THREAD_lock_new();
return global_engine_lock != NULL;
}
return global_engine_lock != NULL;
}
@@
-74,15
+75,11
@@
int engine_free_util(ENGINE *e, int not_locked)
if (e == NULL)
return 1;
if (e == NULL)
return 1;
-#ifdef HAVE_ATOMICS
- CRYPTO_DOWN_REF(&e->struct_ref, &i, global_engine_lock);
-#else
if (not_locked)
if (not_locked)
- CRYPTO_
atomic_add(&e->struct_ref, -1
, &i, global_engine_lock);
+ CRYPTO_
DOWN_REF(&e->struct_ref
, &i, global_engine_lock);
else
i = --e->struct_ref;
else
i = --e->struct_ref;
-#endif
- engine_ref_debug(e, 0, -1)
+ engine_ref_debug(e, 0, -1);
if (i > 0)
return 1;
REF_ASSERT_ISNT(i < 0);
if (i > 0)
return 1;
REF_ASSERT_ISNT(i < 0);
@@
-126,9
+123,12
@@
static int int_cleanup_check(int create)
static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)
{
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;
return NULL;
+ }
item->cb = cb;
return item;
}
item->cb = cb;
return item;
}
@@
-136,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;
void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb)
{
ENGINE_CLEANUP_ITEM *item;
+
if (!int_cleanup_check(1))
return;
item = int_cleanup_item(cb);
if (!int_cleanup_check(1))
return;
item = int_cleanup_item(cb);
@@
-149,8
+150,10
@@
void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb)
if (!int_cleanup_check(1))
return;
item = int_cleanup_item(cb);
if (!int_cleanup_check(1))
return;
item = int_cleanup_item(cb);
- if (item)
- sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item);
+ if (item != NULL) {
+ if (sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item) <= 0)
+ OPENSSL_free(item);
+ }
}
/* The API function that performs all cleanup */
}
/* The API function that performs all cleanup */