From ded252404e30262f6d50e5987564784b28c8f111 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Thu, 6 Nov 2025 08:32:45 +0000 Subject: [PATCH] ThingTemplate: Add null check for ModuleData after creation --- .../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 6fa3f401fa2..5655e1fc25d 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 == NULL) + { + DEBUG_CRASH(("[LINE: %d - FILE: '%s'] Module '%s' not found or failed to create for thing template '%s'. This module is not registered in the ModuleFactory. Please check that the module name is spelled correctly and that the module type is appropriate.", + 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 1e163cfb177..9bfc4b03ba6 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 == NULL) + { + DEBUG_CRASH(("[LINE: %d - FILE: '%s'] Module '%s' not found or failed to create for thing template '%s'. This module is not registered in the ModuleFactory. Please check that the module name is spelled correctly and that the module type is appropriate.", + ini->getLineNum(), ini->getFilename().str(), tokenStr.str(), self->getName().str())); + throw INI_INVALID_DATA; + } + if (data->isAiModuleData()) { Bool replaced = mi->clearAiModuleInfo();