From 40316fa9812750f08462dd32cab884c0b331fc54 Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Tue, 16 May 2000 21:57:12 +0000 Subject: [PATCH] Fix a memory leak. pthread_set_name_np() allocates space for a name, but _thread_gc() was not deallocating it. PR: misc/18504 --- lib/libc_r/uthread/uthread_gc.c | 4 ++++ lib/libpthread/thread/thr_gc.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/libc_r/uthread/uthread_gc.c b/lib/libc_r/uthread/uthread_gc.c index a6ffd4ba58d..cd1f8383a33 100644 --- a/lib/libc_r/uthread/uthread_gc.c +++ b/lib/libc_r/uthread/uthread_gc.c @@ -242,6 +242,10 @@ _thread_gc(pthread_addr_t arg) if (p_stack != NULL) free(p_stack); if (pthread_cln != NULL) + if (pthread_cln->name != NULL) { + /* Free the thread name string. */ + free(pthread_cln->name); + } /* * Free the memory allocated for the thread * structure. diff --git a/lib/libpthread/thread/thr_gc.c b/lib/libpthread/thread/thr_gc.c index a6ffd4ba58d..cd1f8383a33 100644 --- a/lib/libpthread/thread/thr_gc.c +++ b/lib/libpthread/thread/thr_gc.c @@ -242,6 +242,10 @@ _thread_gc(pthread_addr_t arg) if (p_stack != NULL) free(p_stack); if (pthread_cln != NULL) + if (pthread_cln->name != NULL) { + /* Free the thread name string. */ + free(pthread_cln->name); + } /* * Free the memory allocated for the thread * structure.