Check if source location counts are in order when loading traces.

This commit is contained in:
Bartosz Taudul 2023-12-31 14:16:24 +01:00
parent b262cb2428
commit 762582357b
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -33,6 +33,7 @@
#include "../public/common/TracyVersion.hpp" #include "../public/common/TracyVersion.hpp"
#include "TracyFileRead.hpp" #include "TracyFileRead.hpp"
#include "TracyFileWrite.hpp" #include "TracyFileWrite.hpp"
#include "TracyPrint.hpp"
#include "TracySort.hpp" #include "TracySort.hpp"
#include "TracyTaskDispatch.hpp" #include "TracyTaskDispatch.hpp"
#include "TracyWorker.hpp" #include "TracyWorker.hpp"
@ -776,6 +777,13 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks, bool allow
m_data.externalThreadCompress.Load( f ); m_data.externalThreadCompress.Load( f );
f.Read( sz ); f.Read( sz );
if( sz > std::numeric_limits<int16_t>::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<sz; i++ ) for( uint64_t i=0; i<sz; i++ )
{ {
uint64_t ptr; uint64_t ptr;
@ -792,6 +800,13 @@ Worker::Worker( FileRead& f, EventType::Type eventMask, bool bgTasks, bool allow
const auto sle = sz; const auto sle = sz;
f.Read( sz ); f.Read( sz );
if( sz > std::numeric_limits<int16_t>::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 ); m_data.sourceLocationPayload.reserve_exact( sz, m_slab );
for( uint64_t i=0; i<sz; i++ ) for( uint64_t i=0; i<sz; i++ )
{ {