Skip to content

Commit ded2524

Browse files
ThingTemplate: Add null check for ModuleData after creation
1 parent 36f77cb commit ded2524

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

Generals/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,13 @@ void ThingTemplate::parseModuleName(INI* ini, void *instance, void* store, const
515515

516516
ModuleData* data = TheModuleFactory->newModuleDataFromINI(ini, tokenStr, type, moduleTagStr);
517517

518+
if (data == NULL)
519+
{
520+
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.",
521+
ini->getLineNum(), ini->getFilename().str(), tokenStr.str(), self->getName().str()));
522+
throw INI_INVALID_DATA;
523+
}
524+
518525
if (data->isAiModuleData())
519526
{
520527
Bool replaced = mi->clearAiModuleInfo();

GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,13 @@ void ThingTemplate::parseModuleName(INI* ini, void *instance, void* store, const
595595

596596
ModuleData* data = TheModuleFactory->newModuleDataFromINI(ini, tokenStr, type, moduleTagStr);
597597

598+
if (data == NULL)
599+
{
600+
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.",
601+
ini->getLineNum(), ini->getFilename().str(), tokenStr.str(), self->getName().str()));
602+
throw INI_INVALID_DATA;
603+
}
604+
598605
if (data->isAiModuleData())
599606
{
600607
Bool replaced = mi->clearAiModuleInfo();

0 commit comments

Comments
 (0)