From 586c6bf166fd51cc93341ea91469a40c7ad96739 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 31 Dec 2023 13:05:44 +0100 Subject: [PATCH] Hook up source location overflow failures. Note: not tested. Expect some off-by-one bugs. Control flow may fail. Oh no. --- server/TracyWorker.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index ddddf219..2265026b 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -3326,6 +3326,12 @@ void Worker::NewSourceLocation( uint64_t ptr ) { static const SourceLocation emptySourceLocation = {}; + if( m_data.sourceLocation.size() > std::numeric_limits::max() ) + { + SourceLocationOverflowFailure(); + return; + } + m_data.sourceLocation.emplace( ptr, emptySourceLocation ); m_pendingSourceLocation++; m_sourceLocationQueue.push_back( ptr ); @@ -3708,6 +3714,11 @@ void Worker::AddSourceLocationPayload( const char* data, size_t sz ) auto slptr = m_slab.Alloc(); memcpy( slptr, &srcloc, sizeof( srcloc ) ); uint32_t idx = m_data.sourceLocationPayload.size(); + if( idx+1 > std::numeric_limits::max() ) + { + SourceLocationOverflowFailure(); + return; + } m_data.sourceLocationPayloadMap.emplace( slptr, idx ); m_pendingSourceLocationPayload = -int16_t( idx + 1 ); m_data.sourceLocationPayload.push_back( slptr );