Skip to content

Commit 10b1f2c

Browse files
committed
[GEN][ZH] Prevent dereferencing NULL pointer 'pSL' in GameLogic::startNewGame() when starting a new game without a map (#993)
1 parent 692e452 commit 10b1f2c

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

Generals/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,12 +1412,15 @@ void GameLogic::startNewGame( Bool saveGame )
14121412
if (count)
14131413
{
14141414
ScriptList *pSL = TheSidesList->getSideInfo(0)->getScriptList();
1415-
Script *next = scripts[0]->getScript();
1416-
while (next)
1415+
if (pSL != NULL)
14171416
{
1418-
Script *dupe = next->duplicate();
1419-
pSL->addScript(dupe, 0);
1420-
next = next->getNext();
1417+
Script *next = scripts[0]->getScript();
1418+
while (next)
1419+
{
1420+
Script *dupe = next->duplicate();
1421+
pSL->addScript(dupe, 0);
1422+
next = next->getNext();
1423+
}
14211424
}
14221425
}
14231426
for (Int i=0; i<count; ++i)

GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,12 +1574,15 @@ void GameLogic::startNewGame( Bool loadingSaveGame )
15741574
if (count)
15751575
{
15761576
ScriptList *pSL = TheSidesList->getSideInfo(0)->getScriptList();
1577-
Script *next = scripts[0]->getScript();
1578-
while (next)
1577+
if (pSL != NULL)
15791578
{
1580-
Script *dupe = next->duplicate();
1581-
pSL->addScript(dupe, 0);
1582-
next = next->getNext();
1579+
Script *next = scripts[0]->getScript();
1580+
while (next)
1581+
{
1582+
Script *dupe = next->duplicate();
1583+
pSL->addScript(dupe, 0);
1584+
next = next->getNext();
1585+
}
15831586
}
15841587
}
15851588
for (Int i=0; i<count; ++i)

0 commit comments

Comments
 (0)