diff --git a/public/common/TracySystem.cpp b/public/common/TracySystem.cpp index 2a7d997e..301483eb 100644 --- a/public/common/TracySystem.cpp +++ b/public/common/TracySystem.cpp @@ -213,21 +213,24 @@ TRACY_API const char* GetThreadName( uint32_t id ) # else static auto _GetThreadDescription = (t_GetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetThreadDescription" ); # endif - if( _GetThreadDescription ) - { - auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)id ); - if( hnd != 0 ) - { - PWSTR tmp; - _GetThreadDescription( hnd, &tmp ); - auto ret = wcstombs( buf, tmp, 256 ); - CloseHandle( hnd ); - if( ret != 0 ) - { - return buf; - } - } - } + if( _GetThreadDescription ) + { + auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)id ); + if( hnd != 0 ) + { + PWSTR tmp; + if( SUCCEEDED( _GetThreadDescription( hnd, &tmp ) ) ) + { + auto ret = wcstombs( buf, tmp, 256 ); + CloseHandle( hnd ); + LocalFree( tmp ); + if( ret != static_cast( -1 ) ) + { + return buf; + } + } + } + } #elif defined __linux__ int cs, fd; char path[32];