Skip to content

Commit

Permalink
Fix stack-overflow in demo_extract_chat tool
Browse files Browse the repository at this point in the history
Don't store `CSnapshotDelta` object on the stack, as it's currently 524560 bytes large.

See ddnet#9234, which almost doubled the size of `CSnapshotDelta` due to the type being changed from `int` to `uint64_t`.
  • Loading branch information
Robyt3 committed Dec 9, 2024
1 parent cfefe25 commit 6002f0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tools/demo_extract_chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include <game/gamecore.h>

#include <memory>

static const char *TOOL_NAME = "demo_extract_chat";

class CClientSnapshotHandler
Expand Down Expand Up @@ -195,8 +197,8 @@ class CDemoPlayerMessageListener : public CDemoPlayer::IListener

static int ExtractDemoChat(const char *pDemoFilePath, IStorage *pStorage)
{
CSnapshotDelta DemoSnapshotDelta;
CDemoPlayer DemoPlayer(&DemoSnapshotDelta, false);
std::unique_ptr<CSnapshotDelta> pDemoSnapshotDelta = std::make_unique<CSnapshotDelta>();
CDemoPlayer DemoPlayer(pDemoSnapshotDelta.get(), false);

if(DemoPlayer.Load(pStorage, nullptr, pDemoFilePath, IStorage::TYPE_ALL_OR_ABSOLUTE) == -1)
{
Expand Down

0 comments on commit 6002f0f

Please sign in to comment.