From f156cd922b4c34b5fda838225ab0647a4f517e81 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 15 Oct 2017 13:26:05 +0200 Subject: [PATCH] OpenThread may fail. --- common/TracySystem.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/common/TracySystem.cpp b/common/TracySystem.cpp index a6f02adc..b725f20a 100644 --- a/common/TracySystem.cpp +++ b/common/TracySystem.cpp @@ -69,13 +69,16 @@ const char* GetThreadName( uint64_t id ) #ifdef _WIN32 # ifdef NTDDI_WIN10_RS2 auto hnd = OpenThread( THREAD_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)id ); - PWSTR tmp; - GetThreadDescription( hnd, &tmp ); - auto ret = wcstombs( buf, tmp, 256 ); - CloseHandle( hnd ); - if( ret != 0 ) + if( hnd != 0 ) { - return buf; + PWSTR tmp; + GetThreadDescription( hnd, &tmp ); + auto ret = wcstombs( buf, tmp, 256 ); + CloseHandle( hnd ); + if( ret != 0 ) + { + return buf; + } } # endif #else