From 9b625f5826ff338d1c23df2c07dc57f9745379dc Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Sat, 11 Oct 2025 03:45:34 +0000 Subject: [PATCH] MissileLauncherBuildingUpdate: Add safety check for destroyed objects --- .../Object/Update/MissileLauncherBuildingUpdate.cpp | 13 +++++++++++++ .../Object/Update/MissileLauncherBuildingUpdate.cpp | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp index 8419869317b..388a4023ea9 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp @@ -72,6 +72,10 @@ void MissileLauncherBuildingUpdate::switchToState(DoorStateType dst) return; const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData(); + + // Safety check: if the module data has been cleared during destruction, don't proceed + if (!d) + return; ModelConditionFlags clr, set; UnsignedInt now = TheGameLogic->getFrame(); switch (dst) @@ -229,6 +233,10 @@ UpdateSleepTime MissileLauncherBuildingUpdate::update( void ) return UPDATE_SLEEP_NONE; const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData(); + + // Safety check: if the module data has been cleared during destruction, don't proceed + if (!d) + return UPDATE_SLEEP_NONE; UnsignedInt now = TheGameLogic->getFrame(); @@ -275,6 +283,11 @@ UpdateSleepTime MissileLauncherBuildingUpdate::update( void ) SpecialPowerTemplate* MissileLauncherBuildingUpdate::getTemplate() const { const MissileLauncherBuildingUpdateModuleData* data = getMissileLauncherBuildingUpdateModuleData(); + + // Safety check: if the module data has been cleared during destruction, return NULL + if (!data) + return NULL; + return data->m_specialPowerTemplate; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp index fd0d04ad8e3..d50f8fbec8e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp @@ -73,6 +73,10 @@ void MissileLauncherBuildingUpdate::switchToState(DoorStateType dst) return; const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData(); + + // Safety check: if the module data has been cleared during destruction, don't proceed + if (!d) + return; ModelConditionFlags clr, set; UnsignedInt now = TheGameLogic->getFrame(); switch (dst) @@ -245,6 +249,10 @@ UpdateSleepTime MissileLauncherBuildingUpdate::update( void ) return UPDATE_SLEEP_NONE; const MissileLauncherBuildingUpdateModuleData* d = getMissileLauncherBuildingUpdateModuleData(); + + // Safety check: if the module data has been cleared during destruction, don't proceed + if (!d) + return UPDATE_SLEEP_NONE; UnsignedInt now = TheGameLogic->getFrame(); @@ -291,6 +299,11 @@ UpdateSleepTime MissileLauncherBuildingUpdate::update( void ) SpecialPowerTemplate* MissileLauncherBuildingUpdate::getTemplate() const { const MissileLauncherBuildingUpdateModuleData* data = getMissileLauncherBuildingUpdateModuleData(); + + // Safety check: if the module data has been cleared during destruction, return NULL + if (!data) + return NULL; + return data->m_specialPowerTemplate; }