diff --git a/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp index 8abd18d352d..7b16c479db6 100644 --- a/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp +++ b/Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp @@ -536,6 +536,13 @@ void ThingTemplate::parseModuleName(INI* ini, void *instance, void* store, const ModuleData* data = TheModuleFactory->newModuleDataFromINI(ini, tokenStr, type, moduleTagStr); + if (!data) + { + DEBUG_CRASH(("[LINE: %d - FILE: '%s'] Module '%s' not found in factory for object '%s'.", + ini->getLineNum(), ini->getFilename().str(), tokenStr.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 c113766a012..941053d237a 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp @@ -616,6 +616,13 @@ void ThingTemplate::parseModuleName(INI* ini, void *instance, void* store, const ModuleData* data = TheModuleFactory->newModuleDataFromINI(ini, tokenStr, type, moduleTagStr); + if (!data) + { + DEBUG_CRASH(("[LINE: %d - FILE: '%s'] Module '%s' not found in factory for object '%s'.", + ini->getLineNum(), ini->getFilename().str(), tokenStr.str(), self->getName().str())); + throw INI_INVALID_DATA; + } + if (data->isAiModuleData()) { Bool replaced = mi->clearAiModuleInfo();