diff --git a/engine/baseclient.cpp b/engine/baseclient.cpp index 45d61c22a..0edc6edd6 100644 --- a/engine/baseclient.cpp +++ b/engine/baseclient.cpp @@ -28,6 +28,7 @@ #include "iregistry.h" #include "sv_main.h" #include "hltvserver.h" +#include #ifdef REPLAY_ENABLED #include "replay_internal.h" @@ -1153,7 +1154,9 @@ void CBaseClient::SendSnapshot( CClientFrame *pFrame ) bool bFailedOnce = false; write_again: - bf_write msg( "CBaseClient::SendSnapshot", m_SnapshotScratchBuffer, sizeof( m_SnapshotScratchBuffer ) ); + // RaphaelIT7: Were deep in networking and the stack can easily get close to an overflow + static thread_local std::unique_ptr pSnapshotScratchBuffer(new unsigned int[g_nScratchBufferSizeAsInt]); + bf_write msg( "CBaseClient::SendSnapshot", pSnapshotScratchBuffer.get(), SNAPSHOT_SCRATCH_BUFFER_SIZE ); TRACE_PACKET( ( "SendSnapshot(%d)\n", pFrame->tick_count ) ); diff --git a/engine/baseclient.h b/engine/baseclient.h index 082ca7c34..299b335d9 100644 --- a/engine/baseclient.h +++ b/engine/baseclient.h @@ -276,8 +276,7 @@ class CBaseClient : public IGameEventListener2, public IClient, public IClientMe { SNAPSHOT_SCRATCH_BUFFER_SIZE = 160000, }; - - unsigned int m_SnapshotScratchBuffer[ SNAPSHOT_SCRATCH_BUFFER_SIZE / 4 ]; + static constexpr int g_nScratchBufferSizeAsInt = SNAPSHOT_SCRATCH_BUFFER_SIZE / sizeof(unsigned int); private: void StartTrace( bf_write &msg );