From c3502a2230a4b3d65dad539e8f2d330ccdbcbcbd Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Mon, 30 Mar 2026 13:11:40 +0000 Subject: [PATCH] bugfix(engine): Prevent silent failure when module data creation fails --- .../Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp | 7 +++++++ .../Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp index a3decd3c458..d386bfbf3af 100644 --- a/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp +++ b/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp @@ -515,6 +515,13 @@ void ThingTemplate::parseModuleName(INI* ini, void *instance, void* store, const ModuleData* data = TheModuleFactory->newModuleDataFromINI(ini, tokenStr, type, moduleTagStr); + if (data == nullptr) + { + DEBUG_CRASH(("[LINE: %d - FILE: '%s'] Module '%s' (tag '%s') could not be created for object '%s'. Module may not be registered in the ModuleFactory.", + ini->getLineNum(), ini->getFilename().str(), tokenStr.str(), moduleTagStr.str(), self->getName().str())); + throw INI_INVALID_DATA; + } + if (data->isAiModuleData()) { Bool replaced = mi->clearAiModuleInfo(); diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp index 54e8b295c96..c0ad60018f2 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp @@ -595,6 +595,13 @@ void ThingTemplate::parseModuleName(INI* ini, void *instance, void* store, const ModuleData* data = TheModuleFactory->newModuleDataFromINI(ini, tokenStr, type, moduleTagStr); + if (data == nullptr) + { + DEBUG_CRASH(("[LINE: %d - FILE: '%s'] Module '%s' (tag '%s') could not be created for object '%s'. Module may not be registered in the ModuleFactory.", + ini->getLineNum(), ini->getFilename().str(), tokenStr.str(), moduleTagStr.str(), self->getName().str())); + throw INI_INVALID_DATA; + } + if (data->isAiModuleData()) { Bool replaced = mi->clearAiModuleInfo();