From 87b0d6b13ca69a00c604602a60284535dc25be1e Mon Sep 17 00:00:00 2001 From: Jose Marcial Vieira Bisneto Date: Wed, 20 Sep 2017 08:29:51 -0300 Subject: [PATCH] Fix the mutex lock when the memory allocation fails in api_listen_thread. Thanks to John Jones for pointing out the problem. --- core/api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/api.c b/core/api.c index cf382af..36029e8 100644 --- a/core/api.c +++ b/core/api.c @@ -538,6 +538,7 @@ void *api_listen_thread (void *ptr) api_list.conns[i] = malloc (sizeof (struct s_conns)); if (!api_list.conns[i]) { libp2p_logger_error("api", "Fail to allocate memory to accept connection.\n"); + pthread_mutex_unlock(&conns_lock); close (s); continue; }