Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,16 @@ void ControlBar::onDrawableDeselected( Drawable *draw )
// set a dirty flag so next time we update we can reconstruct the UI
markUIDirty();

// TheSuperHackers @fix Clear the stale drawable pointer to prevent use-after-free crashes.
// m_currentSelectedDrawable is set in switchToContext but never cleared on drawable destruction.
// When destroyDrawable is called, disregardDrawable -> deselectDrawable -> onDrawableDeselected
// fires before deleteInstance(draw), so this check is safe and prevents the dangling pointer
// from being dereferenced in subsequent update/evaluateContextUI calls.
if( m_currentSelectedDrawable == draw )
{
m_currentSelectedDrawable = nullptr;
}

if (TheInGameUI->getSelectCount() == 0)
{
// we just deselected everything - cancel any pending GUI commands
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,16 @@ void ControlBar::onDrawableDeselected( Drawable *draw )
// set a dirty flag so next time we update we can reconstruct the UI
markUIDirty();

// TheSuperHackers @fix Clear the stale drawable pointer to prevent use-after-free crashes.
// m_currentSelectedDrawable is set in switchToContext but never cleared on drawable destruction.
// When destroyDrawable is called, disregardDrawable -> deselectDrawable -> onDrawableDeselected
// fires before deleteInstance(draw), so this check is safe and prevents the dangling pointer
// from being dereferenced in subsequent update/evaluateContextUI calls.
if( m_currentSelectedDrawable == draw )
{
m_currentSelectedDrawable = nullptr;
}

if (TheInGameUI->getSelectCount() == 0)
{
// we just deselected everything - cancel any pending GUI commands
Expand Down
Loading