From 3e93c615f7a82842cdaeb9f207167f548f969c9f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 3 Apr 2018 16:45:55 +0200 Subject: [PATCH] Fix UB, lose type safety. --- client/TracyProfiler.cpp | 8 ++++---- common/TracyAlign.hpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index b9b8a561..24953a16 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -289,23 +289,23 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) while( item != end ) { uint64_t ptr; - const auto idx = MemRead( &item->hdr.idx ); + const auto idx = MemRead( &item->hdr.idx ); if( idx < (int)QueueType::Terminate ) { switch( (QueueType)idx ) { case QueueType::ZoneText: - ptr = MemRead( &item->zoneText.text ); + ptr = MemRead( &item->zoneText.text ); SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); tracy_free( (void*)ptr ); break; case QueueType::Message: - ptr = MemRead( &item->message.text ); + ptr = MemRead( &item->message.text ); SendString( ptr, (const char*)ptr, QueueType::CustomStringData ); tracy_free( (void*)ptr ); break; case QueueType::ZoneBeginAllocSrcLoc: - ptr = MemRead( &item->zoneBegin.srcloc ); + ptr = MemRead( &item->zoneBegin.srcloc ); SendSourceLocationPayload( ptr ); tracy_free( (void*)ptr ); break; diff --git a/common/TracyAlign.hpp b/common/TracyAlign.hpp index 5e5ec034..2ab631e1 100644 --- a/common/TracyAlign.hpp +++ b/common/TracyAlign.hpp @@ -9,7 +9,7 @@ namespace tracy { template -tracy_force_inline T MemRead( T* ptr ) +tracy_force_inline T MemRead( void* ptr ) { T val; memcpy( &val, ptr, sizeof( T ) ); @@ -17,7 +17,7 @@ tracy_force_inline T MemRead( T* ptr ) } template -tracy_force_inline void MemWrite( T* ptr, T val ) +tracy_force_inline void MemWrite( void* ptr, T val ) { memcpy( ptr, &val, sizeof( T ) ); }