textscreen: Fix use-after-free with mouse press.
When propagating mouse button presses to widgets within the window, return from MouseButtonPress() immediately, or we will fall through to additional code that references the window structure. If the handler for the widget we clicked on closes the window, this will have been freed. This fixed #439. Thanks to DuClare for telling me about this.
This commit is contained in:
parent
63e1c88491
commit
77d7e984d1
1 changed files with 2 additions and 2 deletions
|
|
@ -402,6 +402,7 @@ static void MouseButtonPress(txt_window_t *window, int b)
|
|||
&& y >= widgets->y && y < (signed) (widgets->y + widgets->h))
|
||||
{
|
||||
TXT_WidgetMousePress(window, x, y, b);
|
||||
return;
|
||||
}
|
||||
|
||||
// Was one of the action area buttons pressed?
|
||||
|
|
@ -428,8 +429,7 @@ static void MouseButtonPress(txt_window_t *window, int b)
|
|||
// Pass through mouse press.
|
||||
|
||||
TXT_WidgetMousePress(widget, x, y, b);
|
||||
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue