summaryrefslogtreecommitdiff
path: root/lib/libpthread/thread
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpthread/thread')
-rw-r--r--lib/libpthread/thread/thr_gc.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/libpthread/thread/thr_gc.c b/lib/libpthread/thread/thr_gc.c
index cdc9681a9aae..83ff38fc966f 100644
--- a/lib/libpthread/thread/thr_gc.c
+++ b/lib/libpthread/thread/thr_gc.c
@@ -97,6 +97,10 @@ _thread_gc(pthread_addr_t arg)
*/
_thread_kern_sig_undefer();
+ /* No stack of thread structure to free yet: */
+ p_stack = NULL;
+ pthread_cln = NULL;
+
/*
* Lock the garbage collector mutex which ensures that
* this thread sees another thread exit:
@@ -104,10 +108,6 @@ _thread_gc(pthread_addr_t arg)
if (pthread_mutex_lock(&_gc_mutex) != 0)
PANIC("Cannot lock gc mutex");
- /* No stack of thread structure to free yet: */
- p_stack = NULL;
- pthread_cln = NULL;
-
/*
* Enter a loop to search for the first dead thread that
* has memory to free.
@@ -242,7 +242,7 @@ _thread_gc(pthread_addr_t arg)
*/
if (p_stack != NULL)
free(p_stack);
- if (pthread_cln != NULL)
+ if (pthread_cln != NULL) {
if (pthread_cln->name != NULL) {
/* Free the thread name string. */
free(pthread_cln->name);
@@ -252,6 +252,7 @@ _thread_gc(pthread_addr_t arg)
* structure.
*/
free(pthread_cln);
+ }
}
return (NULL);
}