From 10f8e5032aa47af300c6ff98ae0904004a3d035d Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Thu, 29 Jan 2015 11:55:55 +0100 Subject: [PATCH] base_c: need to free mutex attributes in case of error --- base_c/src/mutex.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/base_c/src/mutex.c b/base_c/src/mutex.c index 47ff982..68b3212 100644 --- a/base_c/src/mutex.c +++ b/base_c/src/mutex.c @@ -71,9 +71,13 @@ int embb_mutex_init(embb_mutex_t* mutex, int type) { pthread_mutexattr_t attributes; if (pthread_mutexattr_init(&attributes) != 0) return EMBB_ERROR; if (pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_RECURSIVE) != 0) { + pthread_mutexattr_destroy(&attributes); + return EMBB_ERROR; + } + if (pthread_mutex_init(mutex, &attributes) != 0) { + pthread_mutexattr_destroy(&attributes); return EMBB_ERROR; } - if (pthread_mutex_init(mutex, &attributes) != 0) return EMBB_ERROR; if (pthread_mutexattr_destroy(&attributes) != 0) return EMBB_ERROR; } return EMBB_SUCCESS; -- libgit2 0.26.0