From fd3169dfce01c8766ffcc5ff6b508a1c383b323f Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 11:04:37 +0000 Subject: [PATCH] W3DModelDraw: Explicitly clear containers in destructor to prevent memory corruption --- .../W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp | 5 +++++ .../W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp index 650f249c5e7..8f1ee44edc8 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp @@ -1095,6 +1095,11 @@ void W3DModelDrawModuleData::validateStuffForTimeAndWeather(const Drawable* draw //------------------------------------------------------------------------------------------------- W3DModelDrawModuleData::~W3DModelDrawModuleData() { + // Explicitly clear containers to ensure proper destruction order and prevent + // memory corruption during shutdown. Each ModelConditionInfo contains a + // PristineBoneInfoMap that must be destroyed properly before implicit cleanup. + m_conditionStates.clear(); + m_transitionMap.clear(); m_conditionStateMap.clear(); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp index 4c2f30d6867..9c44d4e9504 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp @@ -1117,6 +1117,11 @@ void W3DModelDrawModuleData::validateStuffForTimeAndWeather(const Drawable* draw //------------------------------------------------------------------------------------------------- W3DModelDrawModuleData::~W3DModelDrawModuleData() { + // Explicitly clear containers to ensure proper destruction order and prevent + // memory corruption during shutdown. Each ModelConditionInfo contains a + // PristineBoneInfoMap that must be destroyed properly before implicit cleanup. + m_conditionStates.clear(); + m_transitionMap.clear(); m_conditionStateMap.clear(); }