Skip to content

Commit d5bfa6e

Browse files
authored
bugfix(contain): Prevent undefined behaviour when a dead unit enters a container (#2258)
1 parent e0a7a95 commit d5bfa6e

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

Generals/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ void OpenContain::addToContain( Object *rider )
278278
if( rider == nullptr )
279279
return;
280280

281+
// TheSuperHackers @bugfix Stubbjax 06/02/2026 Ensure the rider is not destroyed to prevent a
282+
// likely crash if it enters the container on the same frame. If this occurs with an unpatched
283+
// client present in a match, the game has a small chance to mismatch.
284+
if (rider->isDestroyed())
285+
return;
286+
281287
#if defined(RTS_DEBUG)
282288
if( !isValidContainerFor( rider, false ) )
283289
{

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,12 @@ void OpenContain::addToContain( Object *rider )
293293
if( rider == nullptr )
294294
return;
295295

296+
// TheSuperHackers @bugfix Stubbjax 06/02/2026 Ensure the rider is not destroyed to prevent a
297+
// likely crash if it enters the container on the same frame. If this occurs with an unpatched
298+
// client present in a match, the game has a small chance to mismatch.
299+
if (rider->isDestroyed())
300+
return;
301+
296302
Drawable *riderDraw = rider->getDrawable();
297303
Bool wasSelected = FALSE;
298304
if( riderDraw && riderDraw->isSelected() )

0 commit comments

Comments
 (0)