mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Fix two bugs (#615)
* Fix wrong check for wcstombs return value * Fix memory leak when call GetThreadDescription
This commit is contained in:
parent
95e4e01b10
commit
30fb2b5f89
@ -213,21 +213,24 @@ TRACY_API const char* GetThreadName( uint32_t id )
|
|||||||
# else
|
# else
|
||||||
static auto _GetThreadDescription = (t_GetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetThreadDescription" );
|
static auto _GetThreadDescription = (t_GetThreadDescription)GetProcAddress( GetModuleHandleA( "kernel32.dll" ), "GetThreadDescription" );
|
||||||
# endif
|
# endif
|
||||||
if( _GetThreadDescription )
|
if( _GetThreadDescription )
|
||||||
{
|
{
|
||||||
auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)id );
|
auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)id );
|
||||||
if( hnd != 0 )
|
if( hnd != 0 )
|
||||||
{
|
{
|
||||||
PWSTR tmp;
|
PWSTR tmp;
|
||||||
_GetThreadDescription( hnd, &tmp );
|
if( SUCCEEDED( _GetThreadDescription( hnd, &tmp ) ) )
|
||||||
auto ret = wcstombs( buf, tmp, 256 );
|
{
|
||||||
CloseHandle( hnd );
|
auto ret = wcstombs( buf, tmp, 256 );
|
||||||
if( ret != 0 )
|
CloseHandle( hnd );
|
||||||
{
|
LocalFree( tmp );
|
||||||
return buf;
|
if( ret != static_cast<std::size_t>( -1 ) )
|
||||||
}
|
{
|
||||||
}
|
return buf;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
int cs, fd;
|
int cs, fd;
|
||||||
char path[32];
|
char path[32];
|
||||||
|
Loading…
Reference in New Issue
Block a user