]> git.corax.cc Git - mwm/commitdiff
mwm: Add missing command names
authorMatthias Kruk <m@m10k.eu>
Sun, 23 May 2021 21:20:50 +0000 (06:20 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 23 May 2021 21:20:50 +0000 (06:20 +0900)
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

diff --git a/mwm.c b/mwm.c
index 9b095a4f894ae86f621cc2a310eae21eef1d2321..1556e97f5a6bf708fca74716c6d3683b32c71900 100644 (file)
--- 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) {