From eb9a5c0d3ba782e0c2dc56430fe5e50152714a7a Mon Sep 17 00:00:00 2001 From: deischen Date: Fri, 6 Feb 2004 15:15:44 +0000 Subject: [PATCH] Prevent memory leak on sem_destroy() by destroying the semaphore's internal mutex and CV. --- lib/libc/gen/sem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/libc/gen/sem.c b/lib/libc/gen/sem.c index ec80bc3eab53..64ba05b70b8b 100644 --- a/lib/libc/gen/sem.c +++ b/lib/libc/gen/sem.c @@ -182,8 +182,11 @@ __sem_destroy(sem_t *sem) } _pthread_mutex_unlock(&(*sem)->lock); - if (retval == 0) + if (retval == 0) { + _pthread_mutex_destroy(&(*sem)->lock); + _pthread_cond_destroy(&(*sem)->gtzero); sem_free(*sem); + } return (retval); }