libfreerdp-utils: fix a handle leak while creating threads under win32

This commit is contained in:
louyihua 2011-12-21 08:50:47 +08:00
parent 95b03f96ef
commit d095c2398e

View File

@ -24,6 +24,9 @@
#ifdef _WIN32
#include <Windows.h>
#ifdef _MSC_VER
#include <process.h>
#endif
#endif
#include <freerdp/utils/sleep.h>
@ -49,8 +52,11 @@ void freerdp_thread_start(freerdp_thread* thread, void* func, void* arg)
#ifdef _WIN32
{
DWORD th;
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, &th);
# ifdef _MSC_VER
CloseHandle((HANDLE)_beginthreadex(NULL, 0, func, arg, 0, NULL));
#else
CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, NULL));
#endif
}
#else
{