From 631a7696eef8471bdaec883b7f2a521b416a03ff Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Mon, 26 Jan 2026 05:29:28 +0000 Subject: [PATCH] Fix crash during game shutdown when repositioning objects --- .../Source/GameLogic/Object/Contain/OpenContain.cpp | 12 ++++++++++++ .../Source/GameLogic/Object/Contain/OpenContain.cpp | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp index 9d5aef9352f..6d0379a3c69 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp @@ -1092,6 +1092,12 @@ void OpenContain::monitorConditionChanges( void ) void OpenContain::redeployOccupants( void ) { + // TheSuperHackers @fix xezon 09/06/2025 Prevent repositioning objects during game shutdown. + // During shutdown, objects may be in the process of being destroyed, which can lead to + // use-after-free crashes if we attempt to reposition them. + if( TheGameLogic == nullptr || !TheGameLogic->isInGame() ) + return; + // // because the state has changed, we will must give the deploy logic the opportunity // to look for a new set of bones in the art ... so if we had them flagged as not @@ -1121,6 +1127,12 @@ void OpenContain::redeployOccupants( void ) void OpenContain::putObjAtNextFirePoint( Object *obj ) { + // TheSuperHackers @fix xezon 09/06/2025 Prevent repositioning objects during game shutdown. + // During shutdown, objects may be in the process of being destroyed, which can lead to + // use-after-free crashes if we attempt to reposition them. + if( TheGameLogic == nullptr || !TheGameLogic->isInGame() ) + return; + // // first, if we need to load the 3D point data from the art do so, if we've already // determined there is no firepoints in the current art we will avoid searching for diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp index fd99fe3d9b6..7ace4b3728b 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp @@ -1214,6 +1214,12 @@ void OpenContain::monitorConditionChanges( void ) void OpenContain::redeployOccupants( void ) { + // TheSuperHackers @fix xezon 09/06/2025 Prevent repositioning objects during game shutdown. + // During shutdown, objects may be in the process of being destroyed, which can lead to + // use-after-free crashes if we attempt to reposition them. + if( TheGameLogic == nullptr || !TheGameLogic->isInGame() ) + return; + // // because the state has changed, we will must give the deploy logic the opportunity // to look for a new set of bones in the art ... so if we had them flagged as not @@ -1243,6 +1249,12 @@ void OpenContain::redeployOccupants( void ) void OpenContain::putObjAtNextFirePoint( Object *obj ) { + // TheSuperHackers @fix xezon 09/06/2025 Prevent repositioning objects during game shutdown. + // During shutdown, objects may be in the process of being destroyed, which can lead to + // use-after-free crashes if we attempt to reposition them. + if( TheGameLogic == nullptr || !TheGameLogic->isInGame() ) + return; + // // first, if we need to load the 3D point data from the art do so, if we've already // determined there is no firepoints in the current art we will avoid searching for