From 852d636b39cfb6ff9e72775acfd2226982e338d7 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Mon, 16 Jul 2018 13:41:58 +0200 Subject: [PATCH] Destroying a locked mutex is undefined behaviour --- src/threadpool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/threadpool.c b/src/threadpool.c index 1fe3fb0..fcfe7da 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -255,6 +255,7 @@ int threadpool_free(threadpool_t *pool) mutex and condition variable, we're sure they're initialized. Let's lock the mutex just in case. */ pthread_mutex_lock(&(pool->lock)); + pthread_mutex_unlock(&(pool->lock)); pthread_mutex_destroy(&(pool->lock)); pthread_cond_destroy(&(pool->notify)); }