From ff17f52f915a3c4da0b3bac94fa95ea60a30a90b 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 02:59:48 +0000 Subject: [PATCH] Fix potential crash in AI build logic when thing template is not found --- Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp | 2 +- GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 9bd88bcb319..1bf37586b92 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -1737,7 +1737,7 @@ void AIPlayer::buildBySupplies(Int minimumCash, const AsciiString& thingName) { Object *bestSupplyWarehouse = findSupplyCenter(minimumCash); const ThingTemplate* tTemplate = TheThingFactory->findTemplate(thingName); - if (!tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) { + if (tTemplate && !tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) { // Build by the current warehouse. Object *curWarehouse = TheGameLogic->findObjectByID(m_curWarehouseID); if (curWarehouse) { diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 14c6cfe36f2..4c25ce73add 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -1857,7 +1857,7 @@ void AIPlayer::buildBySupplies(Int minimumCash, const AsciiString& thingName) { Object *bestSupplyWarehouse = findSupplyCenter(minimumCash); const ThingTemplate* tTemplate = TheThingFactory->findTemplate(thingName); - if (!tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) { + if (tTemplate && !tTemplate->isKindOf(KINDOF_CASH_GENERATOR)) { // Build by the current warehouse. Object *curWarehouse = TheGameLogic->findObjectByID(m_curWarehouseID); if (curWarehouse) {