From 3a04b7492290359b8ba05eef99f3b32336973852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Thu, 24 Feb 2011 22:53:01 +0000 Subject: [PATCH] Don't dereference thread after free(). Thanks to Stephan for noticing. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40674 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/os/thread.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/system/libroot/os/thread.c b/src/system/libroot/os/thread.c index 7b11cd70d2..68ce51bafd 100644 --- a/src/system/libroot/os/thread.c +++ b/src/system/libroot/os/thread.c @@ -99,10 +99,12 @@ spawn_thread(thread_func entry, const char *name, int32 priority, void *data) attributes.stack_address = NULL; attributes.stack_size = 0; - thread->id = _kern_spawn_thread(&attributes); - if (thread->id < 0) + thread_id id = _kern_spawn_thread(&attributes); + if (id < 0) free(thread); - return thread->id; + else + thread->id = id; + return id; }