Skip to content

Commit 61cbc6f

Browse files
authored
[GEN][ZH] Prevent dereferencing NULL pointer 'theTemplate' in UpgradeMuxData::getUpgradeActivationMasks() (#1141)
1 parent b9318ec commit 61cbc6f

File tree

2 files changed

+12
-10
lines changed
  • GeneralsMD/Code/GameEngine/Source/Common/Thing
  • Generals/Code/GameEngine/Source/Common/Thing

2 files changed

+12
-10
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ void UpgradeMuxData::getUpgradeActivationMasks(UpgradeMaskType& activation, Upgr
261261
it++)
262262
{
263263
const UpgradeTemplate* theTemplate = TheUpgradeCenter->findUpgrade( *it );
264-
if( !theTemplate && !it->isEmpty() && !it->isNone())
264+
if( !theTemplate )
265265
{
266-
DEBUG_CRASH(("An upgrade module references %s, which is not an Upgrade", it->str()));
266+
DEBUG_CRASH(("An upgrade module references '%s', which is not an Upgrade", it->str()));
267267
throw INI_INVALID_DATA;
268268
}
269269

@@ -275,11 +275,12 @@ void UpgradeMuxData::getUpgradeActivationMasks(UpgradeMaskType& activation, Upgr
275275
it++)
276276
{
277277
const UpgradeTemplate* theTemplate = TheUpgradeCenter->findUpgrade( *it );
278-
if( !theTemplate && !it->isEmpty() && !it->isNone())
278+
if( !theTemplate )
279279
{
280-
DEBUG_CRASH(("An upgrade module references %s, which is not an Upgrade", it->str()));
280+
DEBUG_CRASH(("An upgrade module references '%s', which is not an Upgrade", it->str()));
281281
throw INI_INVALID_DATA;
282282
}
283+
283284
m_conflictingMask.set( theTemplate->getUpgradeMask() );
284285
}
285286

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ void UpgradeMuxData::muxDataProcessUpgradeRemoval(Object* obj) const
257257
it++)
258258
{
259259
const UpgradeTemplate* theTemplate = TheUpgradeCenter->findUpgrade( *it );
260-
if( !theTemplate && !it->isEmpty() && !it->isNone())
260+
if( !theTemplate )
261261
{
262-
DEBUG_CRASH(("An upgrade module references %s, which is not an Upgrade", it->str()));
262+
DEBUG_CRASH(("An upgrade module references '%s', which is not an Upgrade", it->str()));
263263
throw INI_INVALID_DATA;
264264
}
265265

@@ -299,9 +299,9 @@ void UpgradeMuxData::getUpgradeActivationMasks(UpgradeMaskType& activation, Upgr
299299
it++)
300300
{
301301
const UpgradeTemplate* theTemplate = TheUpgradeCenter->findUpgrade( *it );
302-
if( !theTemplate && !it->isEmpty() && !it->isNone())
302+
if( !theTemplate )
303303
{
304-
DEBUG_CRASH(("An upgrade module references %s, which is not an Upgrade", it->str()));
304+
DEBUG_CRASH(("An upgrade module references '%s', which is not an Upgrade", it->str()));
305305
throw INI_INVALID_DATA;
306306
}
307307

@@ -313,11 +313,12 @@ void UpgradeMuxData::getUpgradeActivationMasks(UpgradeMaskType& activation, Upgr
313313
it++)
314314
{
315315
const UpgradeTemplate* theTemplate = TheUpgradeCenter->findUpgrade( *it );
316-
if( !theTemplate && !it->isEmpty() && !it->isNone())
316+
if( !theTemplate )
317317
{
318-
DEBUG_CRASH(("An upgrade module references %s, which is not an Upgrade", it->str()));
318+
DEBUG_CRASH(("An upgrade module references '%s', which is not an Upgrade", it->str()));
319319
throw INI_INVALID_DATA;
320320
}
321+
321322
m_conflictingMask.set( theTemplate->getUpgradeMask() );
322323
}
323324

0 commit comments

Comments
 (0)