Minor code cleanup in o_names_init

This might result in a small memory leak.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17238)
This commit is contained in:
Bernd Edlinger 2021-12-08 14:14:48 +01:00
parent f0d5a3b6ea
commit c50bf14450
1 changed files with 7 additions and 1 deletions

View File

@ -66,8 +66,14 @@ static int obj_name_cmp(const OBJ_NAME *a, const OBJ_NAME *b);
static CRYPTO_ONCE init = CRYPTO_ONCE_STATIC_INIT;
DEFINE_RUN_ONCE_STATIC(o_names_init)
{
names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
names_lh = NULL;
obj_lock = CRYPTO_THREAD_lock_new();
if (obj_lock != NULL)
names_lh = lh_OBJ_NAME_new(obj_name_hash, obj_name_cmp);
if (names_lh == NULL) {
CRYPTO_THREAD_lock_free(obj_lock);
obj_lock = NULL;
}
return names_lh != NULL && obj_lock != NULL;
}