mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-02 07:27:19 +08: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
|
#else
|
||||||
controls.window = X11Toolkit_CreateWindowStruct(parent_window, NULL, SDL_TOOLKIT_WINDOW_MODE_X11_DIALOG, colorhints, false);
|
controls.window = X11Toolkit_CreateWindowStruct(parent_window, NULL, SDL_TOOLKIT_WINDOW_MODE_X11_DIALOG, colorhints, false);
|
||||||
#endif
|
#endif
|
||||||
controls.window->cb_data = &controls;
|
|
||||||
controls.window->cb_on_scale_change = X11_OnMessageBoxScaleChange;
|
|
||||||
if (!controls.window) {
|
if (!controls.window) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
controls.window->cb_data = &controls;
|
||||||
|
controls.window->cb_on_scale_change = X11_OnMessageBoxScaleChange;
|
||||||
|
|
||||||
/* Create controls */
|
/* Create controls */
|
||||||
controls.buttonID = buttonID;
|
controls.buttonID = buttonID;
|
||||||
|
|||||||
Reference in New Issue
Block a user