From 8c7e7fbd5eee76810599184d77aa321cee7a61d5 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Sat, 3 Jan 2026 01:56:53 +0000 Subject: [PATCH] Fix potential crash when sticky bomb target is invalid --- .../Source/GameLogic/Object/Update/StickyBombUpdate.cpp | 7 +++++++ .../Source/GameLogic/Object/Update/StickyBombUpdate.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp index 0b7ca867061..59f818912a9 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp @@ -193,6 +193,13 @@ UpdateSleepTime StickyBombUpdate::update( void ) //------------------------------------------------------------------------------------------------- Object* StickyBombUpdate::getTargetObject() const { + // Validate the target ID before attempting to find the object + // This prevents crashes when the target has been destroyed but m_targetID still holds the old ID + if( m_targetID == INVALID_ID ) + { + return NULL; + } + return TheGameLogic->findObjectByID( m_targetID ); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp index a94c348d04b..2ff20f24c6b 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp @@ -215,6 +215,13 @@ UpdateSleepTime StickyBombUpdate::update( void ) //------------------------------------------------------------------------------------------------- Object* StickyBombUpdate::getTargetObject() const { + // Validate the target ID before attempting to find the object + // This prevents crashes when the target has been destroyed but m_targetID still holds the old ID + if( m_targetID == INVALID_ID ) + { + return NULL; + } + return TheGameLogic->findObjectByID( m_targetID ); }