mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-02 22:30:13 +02:00
X11TK: fix late null-check causing segfault
The code is using `controls.window` before checking if it isn't null.
I found this bug by accident when I tried to run `SDL_ShowSimpleMessageBox`.
It first tried using Wayland with `zenity`, but since I don't have `zenity`, it fallbacked to `X11_ShowMessageBoxImpl`.
For some reason it couldn't create a window, maybe something related to XWayland, so `controls.window` was `NULL`.
(cherry picked from commit e70f1bfc29)
This commit is contained in:
@@ -250,11 +250,11 @@ static bool X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int
|
||||
#else
|
||||
controls.window = X11Toolkit_CreateWindowStruct(parent_window, NULL, SDL_TOOLKIT_WINDOW_MODE_X11_DIALOG, colorhints, false);
|
||||
#endif
|
||||
controls.window->cb_data = &controls;
|
||||
controls.window->cb_on_scale_change = X11_OnMessageBoxScaleChange;
|
||||
if (!controls.window) {
|
||||
return false;
|
||||
}
|
||||
controls.window->cb_data = &controls;
|
||||
controls.window->cb_on_scale_change = X11_OnMessageBoxScaleChange;
|
||||
|
||||
/* Create controls */
|
||||
controls.buttonID = buttonID;
|
||||
|
||||
Reference in New Issue
Block a user