From 9bbc6c7f542bdaaedcbb8ed47f15a508c2e49c4e Mon Sep 17 00:00:00 2001 From: David Xu Date: Wed, 12 Jul 2006 03:44:05 +0000 Subject: [PATCH] __error could be called too early before libthr is initialized, test this case and return global varible errno instead. --- lib/libthr/sys/thr_error.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/libthr/sys/thr_error.c b/lib/libthr/sys/thr_error.c index 902c054900c2..45295c5e211d 100644 --- a/lib/libthr/sys/thr_error.c +++ b/lib/libthr/sys/thr_error.c @@ -45,10 +45,12 @@ extern int errno; int * __error(void) { - struct pthread *curthread = _get_curthread(); + struct pthread *curthread; - if (curthread != NULL && curthread != _thr_initial) - return (&curthread->error); - else - return (&errno); + if (_thr_initial != NULL) { + curthread = _get_curthread(); + if (curthread != NULL && curthread != _thr_initial) + return (&curthread->error); + } + return (&errno); }