Skip to content

Commit 6284c15

Browse files
committed
BWM: null-guard shortcut-bar button derefs (fix >11 crash)
1 parent d807621 commit 6284c15

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3502,8 +3502,8 @@ void ControlBar::populateSpecialPowerShortcut( Player *player)
35023502
}
35033503
}
35043504

3505-
DEBUG_ASSERTCRASH(m_specialPowerShortcutButtons[ currentButton ] != nullptr, ("m_specialPowerShortcutButtons[%d] is null", currentButton));
3506-
DEBUG_ASSERTCRASH(m_specialPowerShortcutButtonParents[ currentButton ] != nullptr, ("m_specialPowerShortcutButtonParents[%d] is null", currentButton));
3505+
if( m_specialPowerShortcutButtons[ currentButton ] == nullptr || m_specialPowerShortcutButtonParents[ currentButton ] == nullptr ) break;
3506+
// parent null-checked above
35073507

35083508
// make sure the window is not hidden
35093509
m_specialPowerShortcutButtons[ currentButton ]->winHide( FALSE );
@@ -3537,6 +3537,7 @@ Bool ControlBar::hasAnyShortcutSelection() const
35373537
const CommandButton *command;
35383538

35393539
win = m_specialPowerShortcutButtons[ i ];
3540+
if( win == nullptr ) continue;
35403541
if( win->winIsHidden() == TRUE )
35413542
continue;
35423543

@@ -3614,6 +3615,7 @@ void ControlBar::updateSpecialPowerShortcut()
36143615
const CommandButton *command;
36153616
// get the window
36163617
win = m_specialPowerShortcutButtons[ i ];
3618+
if( win == nullptr ) continue;
36173619

36183620
if( win->winIsHidden() == TRUE )
36193621
continue;
@@ -3706,6 +3708,7 @@ void ControlBar::drawSpecialPowerShortcutMultiplierText()
37063708
const CommandButton *command;
37073709
// get the window
37083710
win = m_specialPowerShortcutButtons[ i ];
3711+
if( win == nullptr ) continue;
37093712

37103713
if( win->winIsHidden() == TRUE )
37113714
continue;
@@ -3758,7 +3761,7 @@ void ControlBar::animateSpecialPowerShortcut( Bool isOn )
37583761
Bool dontAnimate = TRUE;
37593762
for( Int i = 0; i < m_currentlyUsedSpecialPowersButtons; ++i )
37603763
{
3761-
if (m_specialPowerShortcutButtons[i]->winGetUserData())
3764+
if (m_specialPowerShortcutButtons[i] && m_specialPowerShortcutButtons[i]->winGetUserData())
37623765
{
37633766
dontAnimate = FALSE;
37643767
break;
@@ -3786,7 +3789,7 @@ void ControlBar::showSpecialPowerShortcut()
37863789
Bool dontAnimate = TRUE;
37873790
for( Int i = 0; i < m_currentlyUsedSpecialPowersButtons; ++i )
37883791
{
3789-
if (m_specialPowerShortcutButtons[i]->winGetUserData())
3792+
if (m_specialPowerShortcutButtons[i] && m_specialPowerShortcutButtons[i]->winGetUserData())
37903793
{
37913794
dontAnimate = FALSE;
37923795
break;

0 commit comments

Comments
 (0)