mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Guard against nullptr dereference (#278)
Encountered a situation where a pSoldier between bFirstID and bLastID was null and then we'd dereference it.
This commit is contained in:
@@ -460,7 +460,7 @@ void AutoBandage( BOOLEAN fStart )
|
|||||||
for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++cnt, ++pSoldier )
|
for ( pSoldier = MercPtrs[cnt]; cnt <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++cnt, ++pSoldier )
|
||||||
{
|
{
|
||||||
// 0verhaul: Make sure the merc is also in the sector before making him stand up!
|
// 0verhaul: Make sure the merc is also in the sector before making him stand up!
|
||||||
if ( pSoldier->bActive && pSoldier->bInSector )
|
if (pSoldier && pSoldier->bActive && pSoldier->bInSector)
|
||||||
{
|
{
|
||||||
ActionDone( pSoldier );
|
ActionDone( pSoldier );
|
||||||
if ( pSoldier->bSlotItemTakenFrom != NO_SLOT )
|
if ( pSoldier->bSlotItemTakenFrom != NO_SLOT )
|
||||||
@@ -483,12 +483,16 @@ void AutoBandage( BOOLEAN fStart )
|
|||||||
ubLoop = gTacticalStatus.Team[ gbPlayerNum ].bFirstID;
|
ubLoop = gTacticalStatus.Team[ gbPlayerNum ].bFirstID;
|
||||||
for ( ; ubLoop <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++ubLoop)
|
for ( ; ubLoop <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++ubLoop)
|
||||||
{
|
{
|
||||||
ActionDone( MercPtrs[ ubLoop ] );
|
pSoldier = MercPtrs[ubLoop];
|
||||||
|
if (pSoldier && pSoldier->bActive && pSoldier->bInSector)
|
||||||
// If anyone is still doing aid animation, stop!
|
|
||||||
if ( MercPtrs[ ubLoop ]->usAnimState == GIVING_AID || MercPtrs[ ubLoop ]->usAnimState == GIVING_AID_PRN )
|
|
||||||
{
|
{
|
||||||
MercPtrs[ ubLoop ]->SoldierGotoStationaryStance( );
|
ActionDone(pSoldier);
|
||||||
|
|
||||||
|
// If anyone is still doing aid animation, stop!
|
||||||
|
if (pSoldier->usAnimState == GIVING_AID || pSoldier->usAnimState == GIVING_AID_PRN)
|
||||||
|
{
|
||||||
|
pSoldier->SoldierGotoStationaryStance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user