summaryrefslogtreecommitdiff
path: root/pthread_getspecific.c
diff options
context:
space:
mode:
Diffstat (limited to 'pthread_getspecific.c')
-rw-r--r--pthread_getspecific.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/pthread_getspecific.c b/pthread_getspecific.c
index e48fa47..4cb474c 100644
--- a/pthread_getspecific.c
+++ b/pthread_getspecific.c
@@ -8,7 +8,7 @@
*
* Pthreads-win32 - POSIX Threads Library for Win32
* Copyright(C) 1998 John E. Bossom
- * Copyright(C) 1999,2003 Pthreads-win32 contributors
+ * Copyright(C) 1999,2004 Pthreads-win32 contributors
*
* Contact Email: rpj@callisto.canberra.edu.au
*
@@ -63,13 +63,22 @@ pthread_getspecific (pthread_key_t key)
* ------------------------------------------------------
*/
{
- int lasterror = GetLastError ();
- int lastWSAerror = WSAGetLastError ();
+ void * ptr;
- void *ptr = TlsGetValue (key->key);
+ if (key == NULL)
+ {
+ ptr = NULL;
+ }
+ else
+ {
+ int lasterror = GetLastError ();
+ int lastWSAerror = WSAGetLastError ();
- SetLastError (lasterror);
- WSASetLastError (lastWSAerror);
+ ptr = TlsGetValue (key->key);
+
+ SetLastError (lasterror);
+ WSASetLastError (lastWSAerror);
+ }
return ptr;
}