From 6f77b61df97962518ab38916771863d14ddfca00 Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2026 11:03:34 +0000 Subject: [PATCH] fix: Prevent crash when unknown module referenced in INI --- .../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 8abd18d352d..97fde99ad1a 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'] Unknown module '%s' 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..1c2b79d6961 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'] Unknown module '%s' for Object %s.", + ini->getLineNum(), ini->getFilename().str(), tokenStr.str(), self->getName().str())); + throw INI_INVALID_DATA; + } + if (data->isAiModuleData()) { Bool replaced = mi->clearAiModuleInfo();