mirror of https://github.com/FreeRDP/FreeRDP
winpr: CloseHandle did not release the thread TCB
This resulted in huge memory leaks - 8MB per thread, depending on the system's default stack size. The leak happend even if CloseHandle() was correctly used to "detach" the thread but WaitForSingleObject was never called.
This commit is contained in:
parent
1d8e2fc95f
commit
aac57e7e72
|
@ -139,6 +139,9 @@ BOOL CloseHandle(HANDLE hObject)
|
|||
WINPR_THREAD* thread;
|
||||
|
||||
thread = (WINPR_THREAD*) Object;
|
||||
if (thread->started) {
|
||||
pthread_detach(thread->thread);
|
||||
}
|
||||
free(thread);
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -255,6 +255,8 @@ DWORD WaitForSingleObject(HANDLE hHandle, DWORD dwMilliseconds)
|
|||
else
|
||||
status = pthread_join(thread->thread, &thread_status);
|
||||
|
||||
thread->started = FALSE;
|
||||
|
||||
if (status != 0)
|
||||
{
|
||||
fprintf(stderr, "WaitForSingleObject: pthread_join failure: [%d] %s\n",
|
||||
|
|
Loading…
Reference in New Issue