mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Fix ubID underflow
Fixes illegal memory access if we tried to find previous merc and our currently selected one has ubID == 0
This commit is contained in:
@@ -4896,7 +4896,13 @@ SoldierID FindPrevActiveAndAliveMerc( SOLDIERTYPE *pSoldier, BOOLEAN fGoodForLes
|
||||
SoldierID bLastTeamID = gTacticalStatus.Team[ pSoldier->bTeam ].bFirstID;
|
||||
SoldierID cnt = pSoldier->ubID - 1;
|
||||
|
||||
for ( ; cnt > bLastTeamID; --cnt )
|
||||
// Guard against ubID underflow. We'll start searching for previous merc from the lastID in that case
|
||||
if ( cnt >= NOBODY )
|
||||
{
|
||||
cnt = gTacticalStatus.Team[pSoldier->bTeam].bLastID;
|
||||
}
|
||||
|
||||
for ( ; cnt >= bLastTeamID; --cnt )
|
||||
{
|
||||
pTeamSoldier = cnt;
|
||||
if ( fOnlyRegularMercs )
|
||||
|
||||
Reference in New Issue
Block a user