diff --git a/public/common/TracySystem.cpp b/public/common/TracySystem.cpp index 05a16c43..0d79ad30 100644 --- a/public/common/TracySystem.cpp +++ b/public/common/TracySystem.cpp @@ -219,12 +219,15 @@ TRACY_API const char* GetThreadName( uint32_t id ) if( hnd != 0 ) { PWSTR tmp; - _GetThreadDescription( hnd, &tmp ); - auto ret = wcstombs( buf, tmp, 256 ); - CloseHandle( hnd ); - if( ret != static_cast(-1) ) + if ( SUCCEEDED( _GetThreadDescription( hnd, &tmp ) ) ) { - return buf; + auto ret = wcstombs( buf, tmp, 256 ); + CloseHandle( hnd ); + LocalFree( tmp ); + if( ret != static_cast(-1) ) + { + return buf; + } } } }