Skip to content

Commit e2064f2

Browse files
authored
[GEN][ZH] Fix dangling pointer at Player::m_defaultTeam when Team is destroyed (#809)
1 parent 0f96db4 commit e2064f2

File tree

2 files changed

+8
-0
lines changed
  • GeneralsMD/Code/GameEngine/Source/Common/RTS
  • Generals/Code/GameEngine/Source/Common/RTS

2 files changed

+8
-0
lines changed

Generals/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,10 @@ void Player::preTeamDestroy( const Team *team )
13011301
// ai notification callback
13021302
if( m_ai )
13031303
m_ai->aiPreTeamDestroy( team );
1304+
1305+
// TheSuperHackers @bugfix Mauller/Xezon 03/05/2025 Clear the default team to prevent dangling pointer usage
1306+
if( m_defaultTeam == team )
1307+
m_defaultTeam = NULL;
13041308
} // preTeamDestroy
13051309

13061310
//-------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,10 @@ void Player::preTeamDestroy( const Team *team )
16521652
// ai notification callback
16531653
if( m_ai )
16541654
m_ai->aiPreTeamDestroy( team );
1655+
1656+
// TheSuperHackers @bugfix Mauller/Xezon 03/05/2025 Clear the default team to prevent dangling pointer usage
1657+
if( m_defaultTeam == team )
1658+
m_defaultTeam = NULL;
16551659
} // preTeamDestroy
16561660

16571661
//-------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)