diff --git a/dtrans/test/win32/dnd/atlwindow.cxx b/dtrans/test/win32/dnd/atlwindow.cxx index 7aa0df7ce0ac074a4b7f78589c7ab2625a90064e..9e1e2e1fc693fa6c1f91b4ab423c132a88ba97ff 100644 --- a/dtrans/test/win32/dnd/atlwindow.cxx +++ b/dtrans/test/win32/dnd/atlwindow.cxx @@ -181,7 +181,7 @@ LRESULT AWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled data.evtThreadReady= CreateEvent( NULL, FALSE, FALSE, NULL); - HANDLE hThread= CreateThread( NULL, 0, MTAFunc, &data, 0, &mtaThreadId); + CloseHandle(CreateThread(NULL, 0, MTAFunc, &data, 0, &mtaThreadId)); // We must wait until the thread copied the ThreadData structure WaitForSingleObject( data.evtThreadReady, INFINITE); CloseHandle( data.evtThreadReady); diff --git a/sal/osl/w32/dllentry.cxx b/sal/osl/w32/dllentry.cxx index 8e8c0feda62cd38625acf82fe6973dcca19804d7..e9323248e3db5ea7b0e47e641564a547f370d090 100644 --- a/sal/osl/w32/dllentry.cxx +++ b/sal/osl/w32/dllentry.cxx @@ -221,13 +221,17 @@ BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID ) { // No error check, it works or it does not // Thread should only be started for headless mode, see desktop/win32/source/officeloader.cxx - CreateThread( nullptr, 0, ParentMonitorThreadProc, reinterpret_cast(dwParentProcessId), 0, &dwThreadId ); + HANDLE hThread + = CreateThread(nullptr, 0, ParentMonitorThreadProc, + reinterpret_cast(dwParentProcessId), 0, &dwThreadId); // Note: calling CreateThread in DllMain is discouraged // but this is only done in the headless mode and in // that case no other threads should be running at startup // when sal3.dll is loaded; also there is no // synchronization with the spawned thread, so there // does not appear to be a real risk of deadlock here + if (hThread) + CloseHandle(hThread); } } diff --git a/sfx2/source/appl/shutdowniconw32.cxx b/sfx2/source/appl/shutdowniconw32.cxx index 8ff9c621009d901257ef920a2415f5152b3a8cdb..47fb95c37f4a4d2fe9a401cbfdfb0c7fe58ba6e2 100644 --- a/sfx2/source/appl/shutdowniconw32.cxx +++ b/sfx2/source/appl/shutdowniconw32.cxx @@ -528,7 +528,7 @@ void win32_init_sys_tray() ); DWORD dwThreadId; - CreateThread( nullptr, 0, SystrayThread, nullptr, 0, &dwThreadId ); + CloseHandle(CreateThread(nullptr, 0, SystrayThread, nullptr, 0, &dwThreadId)); } }