*** win/tclWinNotify.c 1999/07/02 22:08:28 1.5 --- win/tclWinNotify.c 2000/06/05 00:50:37 *************** *** 150,155 **** --- 150,163 ---- { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) clientData; + /* + * Should the operating system call DllMain() with + * DLL_PROCESS_DETACH from any alternate thread path, such + * as Task Manager terminating the process, tsdPtr will + * be NULL and invalid. + */ + if (tsdPtr == NULL) return; + DeleteCriticalSection(&tsdPtr->crit); CloseHandle(tsdPtr->event);