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`.
This commit is contained in:
Igor
2026-05-01 18:01:13 -03:00
committed by Frank Praznik
parent 1cb61df1e5
commit e70f1bfc29

View File

@@ -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;