From 0fc66f8088acc74f212e273b86fcfa07417ecb27 Mon Sep 17 00:00:00 2001 From: bobtista Date: Thu, 29 Jan 2026 12:06:32 -0600 Subject: [PATCH] Fix use-after-free crash when replay ends in headless mode --- GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp index c3094604143..9781fc4c28c 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp @@ -478,6 +478,15 @@ void RecorderClass::stopPlayback() { if (!m_doingAnalysis) { + // TheSuperHackers @bugfix bobtista 29/01/2026 In headless mode, exit directly to avoid + // use-after-free crash during normal game cleanup. The crash occurs because objects are + // accessed after being freed during TheGameEngine->reset(). Since headless mode has no UI + // and is about to exit anyway, we can safely skip the cleanup and let the OS reclaim resources. + if (TheGlobalData->m_headless) + { + exit(0); + } + TheGameLogic->exitGame(); } }