From 514298ff6ed5841ee771673e7f58885ade0c700e Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Mon, 23 Apr 2012 20:16:05 -0700 Subject: [PATCH] threads: cleanup inconsistencies in memory management --- threads.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/threads.cc b/threads.cc index 7d4d22e..7e23f59 100644 --- a/threads.cc +++ b/threads.cc @@ -58,7 +58,8 @@ void Thread::complete() if (state != THREAD_COMPLETED) { DEBUG("completed thread %d\n", get_id()); state = THREAD_COMPLETED; - stack_free(stack); + if (stack) + stack_free(stack); } } @@ -85,10 +86,11 @@ Thread::Thread(thrd_t *t) { start_routine = NULL; arg = NULL; + create_context(); + stack = NULL; state = THREAD_CREATED; id = model->get_next_id(); *user_thread = id; - create_context(); model->add_system_thread(this); } -- 2.34.1