__error could be called too early before libthr is initialized, test

this case and return global varible errno instead.
This commit is contained in:
David Xu 2006-07-12 03:44:05 +00:00
parent b31da03fd8
commit 9bbc6c7f54
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=160284

View File

@ -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);
}