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.
"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) {