* win32_threads.c (GC_pthread_join): Call GC_lookup_pthread only if
needed (in case of pthreads-w32 target).
* win32_threads.c (GC_pthread_join, GC_pthread_detach): If no thread
is found by GC_lookup_pthread (e.g., the thread has not been created
by GC_pthread_create) then abort with the appropriate message (instead
of null pointer dereference).
result = pthread_join(pthread_id, retval);
-# ifdef GC_WIN32_PTHREADS
- /* win32_pthreads id are unique */
- t = GC_lookup_pthread(pthread_id);
-# endif
-
if (!GC_win32_dll_threads) {
DCL_LOCK_STATE;
+# ifdef GC_WIN32_PTHREADS
+ /* win32_pthreads id are unique */
+ t = GC_lookup_pthread(pthread_id);
+ if (NULL == t) ABORT("Thread not registered");
+# endif
+
LOCK();
GC_delete_gc_thread(t);
UNLOCK();
UNLOCK();
result = pthread_detach(thread);
if (result == 0) {
+ if (NULL == t) ABORT("Thread not registered");
LOCK();
t -> flags |= DETACHED;
/* Here the pthread thread id may have been recycled. */