From 3b1909b5bd4efe20c3e13b8b6029f38609fb41a0 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 22:55:32 +0000 Subject: [PATCH] Fix: Prevent null dereference in SpecialPowerModule --- .../GameLogic/Object/SpecialPower/SpecialPowerModule.cpp | 3 ++- .../GameLogic/Object/SpecialPower/SpecialPowerModule.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp index 1902010dda7..114d0bbc59c 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp @@ -110,7 +110,7 @@ SpecialPowerModule::SpecialPowerModule( Thing *thing, const ModuleData *moduleDa { //A sharedNSync special only startPowerRecharges when first scienced or when executed, //Since a new modue with same SPTemplates may construct at any time. - if ( getSpecialPowerTemplate()->isSharedNSync() == FALSE ) + if ( getSpecialPowerTemplate() != nullptr && getSpecialPowerTemplate()->isSharedNSync() == FALSE ) startPowerRecharge(); } // WE USED TO DO THE POLL-EVERYBODY-AND-VOTE-ON-WHO-TO-SYNC-TO THING HERE, @@ -128,6 +128,7 @@ SpecialPowerModule::SpecialPowerModule( Thing *thing, const ModuleData *moduleDa // lets make sure TheIngameUI knows about our public timer // add this weapon to the UI if it has a public timer for all to see if( m_pausedCount == 0 && + getSpecialPowerTemplate() != nullptr && getSpecialPowerTemplate()->isSharedNSync() == TRUE && getSpecialPowerTemplate()->hasPublicTimer() == TRUE && getObject()->getControllingPlayer() && diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp index 55fc55da9cb..f57bf5e03d6 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp @@ -113,7 +113,7 @@ SpecialPowerModule::SpecialPowerModule( Thing *thing, const ModuleData *moduleDa { //A sharedNSync special only startPowerRecharges when first scienced or when executed, //Since a new module with same SPTemplates may construct at any time. - if ( getSpecialPowerTemplate()->isSharedNSync() == FALSE ) + if ( getSpecialPowerTemplate() != nullptr && getSpecialPowerTemplate()->isSharedNSync() == FALSE ) startPowerRecharge(); } // WE USED TO DO THE POLL-EVERYBODY-AND-VOTE-ON-WHO-TO-SYNC-TO THING HERE, @@ -131,6 +131,7 @@ SpecialPowerModule::SpecialPowerModule( Thing *thing, const ModuleData *moduleDa // lets make sure TheIngameUI knows about our public timer // add this weapon to the UI if it has a public timer for all to see if( m_pausedCount == 0 && + getSpecialPowerTemplate() != nullptr && getSpecialPowerTemplate()->isSharedNSync() == TRUE && getSpecialPowerTemplate()->hasPublicTimer() == TRUE && getObject()->getControllingPlayer() &&