From 2f85308afe216e399a164018d375932dca57093b Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 16 Jan 2015 11:06:35 +0100 Subject: [PATCH] threads: fix missing unlock in error handling If TmThreadsUnregisterThread was called with out of range 'id', a lock would not be cleared after returning from the function. ** CID 1264421: Missing unlock (LOCK) /src/tm-threads.c: 2186 in TmThreadsUnregisterThread() --- src/tm-threads.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tm-threads.c b/src/tm-threads.c index b7fb3a6957..92f35e5178 100644 --- a/src/tm-threads.c +++ b/src/tm-threads.c @@ -2112,8 +2112,10 @@ int TmThreadsRegisterThread(ThreadVars *tv, const int type) void TmThreadsUnregisterThread(const int id) { SCMutexLock(&thread_store_lock); - if (id <= 0 || id > (int)thread_store.threads_size) + if (id <= 0 || id > (int)thread_store.threads_size) { + SCMutexUnlock(&thread_store_lock); return; + } /* id is one higher than index */ int idx = id - 1;