From 762582357b8c3ee7b04c9dcb512e94fc2aaabc05 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 31 Dec 2023 14:16:24 +0100 Subject: [PATCH] Check if source location counts are in order when loading traces. --- server/TracyWorker.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 2265026b..88e512a9 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -33,6 +33,7 @@ #include "../public/common/TracyVersion.hpp" #include "TracyFileRead.hpp" #include "TracyFileWrite.hpp" +#include "TracyPrint.hpp" #include "TracySort.hpp" #include "TracyTaskDispatch.hpp" #include "TracyWorker.hpp" @@ -776,6 +777,13 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks, bool allow m_data.externalThreadCompress.Load( f ); f.Read( sz ); + if( sz > std::numeric_limits::max() ) + { + s_loadProgress.total.store( 0, std::memory_order_relaxed ); + char buf[256]; + sprintf( buf, "Too many static source locations (%s)", RealToString( sz ) ); + throw LoadFailure( buf ); + } for( uint64_t i=0; i std::numeric_limits::max() ) + { + s_loadProgress.total.store( 0, std::memory_order_relaxed ); + char buf[256]; + sprintf( buf, "Too many dynamic source locations (%s)", RealToString( sz ) ); + throw LoadFailure( buf ); + } m_data.sourceLocationPayload.reserve_exact( sz, m_slab ); for( uint64_t i=0; i