aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libthr/sys/thr_error.c12
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);
}