From 8cba254463603755c316b1271c3978198ff33741 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Mon, 24 May 2021 06:20:50 +0900 Subject: [PATCH] mwm: Add missing command names The array of command names in mwm_cmd() is incomplete, causing the window manager to crash if debugging is enabled and a command is executed whose name is not in the array. This commit adds the missing names to the array and changes the way the index is determined so that similar issues will not occur in the future. --- mwm.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mwm.c b/mwm.c index 9b095a4..1556e97 100644 --- a/mwm.c +++ b/mwm.c @@ -1570,11 +1570,24 @@ int mwm_cmd(struct mwm *mwm, mwm_cmd_t cmd, void *data) "spawn", "show_workspace", "move_to_workspace", + "set_layout", + "shift_focus", + "shift_client", + "shift_monitor_focus", + "shift_workspace", + "kbptr_move", + "kbptr_click", "(invalid)" }; + int nameidx; + + nameidx = sizeof(cmd_names) / sizeof(cmd_names[0]); + if(cmd >= 0 && cmd < nameidx) { + nameidx = cmd; + } fprintf(stderr, "%s(%p, %d [%s], %p)\n", __func__, (void*)mwm, - cmd, cmd_names[cmd < MWM_CMD_MAX ? cmd : MWM_CMD_MAX], data); + cmd, cmd_names[nameidx], data); #endif /* MWM_DEBUG */ if(!mwm || cmd < 0 || cmd >= MWM_CMD_MAX) { -- 2.47.3