From 6e4ea6c3f104f7777af7715266de8358aa9486b4 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 18 Feb 2024 19:31:12 +0100 Subject: [PATCH] evthread: fix NULL dereference in evthread_setup_global_lock_() --- evthread.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/evthread.c b/evthread.c index 9b263b79..26d2a564 100644 --- a/evthread.c +++ b/evthread.c @@ -402,8 +402,9 @@ evthread_setup_global_lock_(void *lock_, unsigned locktype, int enable_locks) } else { /* Case 4: Fill in a debug lock with a real lock */ struct debug_lock *lock = lock_ ? lock_ : debug_lock_alloc(locktype); - EVUTIL_ASSERT(enable_locks && - evthread_lock_debugging_enabled_); + if (!lock) + return NULL; + EVUTIL_ASSERT(enable_locks && evthread_lock_debugging_enabled_); EVUTIL_ASSERT(lock->locktype == locktype); if (!lock->lock) { lock->lock = original_lock_fns_.alloc(