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 <haroldo.santos@gmail.com>
This commit is contained in:
Haroldo Santos authored and Carlos R. Mafra committed 2026-10-21 12:20:34 +01:00
1 parent 535288cec5
commit 56ec56136f
1 file changed
+1 -1
+1 -1
View File
@@ -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]);
}