diff options
author | David Xu <davidxu@FreeBSD.org> | 2006-07-12 03:44:05 +0000 |
---|---|---|
committer | David Xu <davidxu@FreeBSD.org> | 2006-07-12 03:44:05 +0000 |
commit | 9bbc6c7f542bdaaedcbb8ed47f15a508c2e49c4e (patch) | |
tree | 672e4dfc099d4a31ba22adbb69f77693e5d374e5 /lib | |
parent | b31da03fd83d59b6a6a901674fb2428e38d33e00 (diff) | |
download | src-9bbc6c7f542bdaaedcbb8ed47f15a508c2e49c4e.tar.gz src-9bbc6c7f542bdaaedcbb8ed47f15a508c2e49c4e.zip |
__error could be called too early before libthr is initialized, test
this case and return global varible errno instead.
Notes
Notes:
svn path=/head/; revision=160284
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libthr/sys/thr_error.c | 12 |
1 files 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); } |