From 56ec56136f9a7b7926c33f28b012f9726e02ff1c Mon Sep 17 00:00:00 2001 From: Haroldo Santos Date: Sat, 10 Oct 2026 17:14:22 -0400 Subject: [PATCH] wmaker: fix NULL dereference in window shortcut with no focused window The WKBD_WINDOW1..10 handler in dispatchWKBDCommand() receives 'wwin' from handleKeyPress(), which takes it from scr->focused_window. That is NULL when no window is focused, for instance on an empty workspace or right after the last window was closed. If the shortcut slot is empty and some windows are currently selected, the last branch of the handler reads wwin->flags.selected without checking wwin, so pressing the shortcut crashes the window manager. Check that 'wwin' is not NULL before using it, as the other cases of this function already do. Found with the clang static analyzer. Signed-off-by: Haroldo Santos --- src/event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/event.c b/src/event.c index 897b848b..5a934cf9 100644 --- a/src/event.c +++ b/src/event.c @@ -1931,7 +1931,7 @@ static void dispatchWKBDCommand(int command, WScreen *scr, WWindow *wwin, XEvent } else if (scr->selected_windows && WMGetArrayItemCount(scr->selected_windows)) { - if (wwin->flags.selected && scr->selected_windows) { + if (wwin && wwin->flags.selected && scr->selected_windows) { if (scr->shortcutWindows[widx]) { WMFreeArray(scr->shortcutWindows[widx]); }