diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-08-08 15:44:46 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-08-08 15:44:46 +0000 |
commit | ac3f49cb8024c62c4f48182371091e9a52a19273 (patch) | |
tree | 31f8684c59eb4f890f5bfd651a94238f9627e978 /libpthread/linuxthreads/errno.c | |
parent | 58b57e65cc2cee5f33260bef009c074409669564 (diff) |
Patch from Stefan Allius and Edie C. Dost:
In linuxthreads/errno.h the functions __errno_location and
__h_errno_location wasn't safe against calling before the
library is initialized.
Diffstat (limited to 'libpthread/linuxthreads/errno.c')
-rw-r--r-- | libpthread/linuxthreads/errno.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libpthread/linuxthreads/errno.c b/libpthread/linuxthreads/errno.c index ad43be47a..46e2fbb35 100644 --- a/libpthread/linuxthreads/errno.c +++ b/libpthread/linuxthreads/errno.c @@ -20,15 +20,29 @@ #include <netdb.h> #include "pthread.h" #include "internals.h" +#include <stdio.h> +extern int _errno; +extern int _h_errno; int * __errno_location() { - pthread_descr self = thread_self(); - return THREAD_GETMEM (self, p_errnop); + /* check, if the library is initilize */ + if (__pthread_initial_thread_bos != NULL) + { + pthread_descr self = thread_self(); + return THREAD_GETMEM (self, p_errnop); + } + return &_errno; } int * __h_errno_location() { - pthread_descr self = thread_self(); - return THREAD_GETMEM (self, p_h_errnop); + /* check, if the library is initilize */ + if (__pthread_initial_thread_bos != NULL) + { + pthread_descr self = thread_self(); + + return THREAD_GETMEM (self, p_h_errnop); + } + return &_h_errno; } |