Fixed nullptr dereference in void CommonEnterCombatModeCode( ) & added two nullptr safety checks

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9393 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Asdow
2022-08-02 22:29:00 +00:00
parent 9f0a3e03bb
commit f733bda830
2 changed files with 5 additions and 9 deletions
+3 -7
View File
@@ -6106,16 +6106,12 @@ BOOLEAN HandleMultiSelectionMove( INT32 sDestGridNo )
void ResetMultiSelection( )
{
SOLDIERTYPE * pSoldier;
INT32 cnt;
// OK, loop through all guys who are 'multi-selected' and
// Make them move....
cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID;
for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++cnt, pSoldier++ )
INT32 cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID;
for (SOLDIERTYPE* pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++cnt, pSoldier++ )
{
if ( pSoldier->bActive && pSoldier->bInSector )
if ( pSoldier && pSoldier->bActive && pSoldier->bInSector )
{
if ( pSoldier->flags.uiStatusFlags & SOLDIER_MULTI_SELECTED )
{
+2 -2
View File
@@ -6428,7 +6428,7 @@ void CommonEnterCombatModeCode( )
// Loop through all mercs and make go
for ( pSoldier = Menptr, cnt = 0; cnt < TOTAL_SOLDIERS; pSoldier++, ++cnt )
{
if ( pSoldier->bActive )
if ( pSoldier && pSoldier->bActive )
{
if ( pSoldier->bInSector && pSoldier->ubBodyType != CROW )
{
@@ -6440,7 +6440,7 @@ void CommonEnterCombatModeCode( )
pSoldier->EVENT_StopMerc( pSoldier->sGridNo, pSoldier->ubDirection );
// END AI actions
DebugAI(AI_MSG_INFO, MercPtrs[pSoldier->ubAutoBandagingMedic], String("CancelAIAction: enter combat mode"));
DebugAI(AI_MSG_INFO, pSoldier, String("CancelAIAction: enter combat mode"));
CancelAIAction( pSoldier, TRUE );
// turn off AI controlled flag