From 2dbfe0ead959500e0cc8f0ae91e7c91d4ba7dc91 Mon Sep 17 00:00:00 2001 From: Igor <85039990+igorcafe@users.noreply.github.com> Date: Fri, 1 May 2026 18:01:13 -0300 Subject: [PATCH] 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 e70f1bfc29aa0aa9a4c066725df48ab336067d73) --- src/video/x11/SDL_x11messagebox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index 489689692e..64d4938c69 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -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;