=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-send-keys.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- src/usr.bin/tmux/cmd-send-keys.c 2019/03/07 20:24:21 1.45 +++ src/usr.bin/tmux/cmd-send-keys.c 2019/03/12 11:16:50 1.46 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-send-keys.c,v 1.45 2019/03/07 20:24:21 nicm Exp $ */ +/* $OpenBSD: cmd-send-keys.c,v 1.46 2019/03/12 11:16:50 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -61,10 +61,11 @@ struct window_pane *wp = item->target.wp; struct session *s = item->target.s; struct winlink *wl = item->target.wl; - struct window_mode_entry *wme = wp->mode; + struct window_mode_entry *wme; struct key_table *table; struct key_binding *bd; + wme = TAILQ_FIRST(&wp->modes); if (wme == NULL || wme->mode->key_table == NULL) { if (options_get_number(wp->window->options, "xterm-keys")) key |= KEYC_XTERM; @@ -90,7 +91,7 @@ struct session *s = item->target.s; struct winlink *wl = item->target.wl; struct mouse_event *m = &item->shared->mouse; - struct window_mode_entry *wme = wp->mode; + struct window_mode_entry *wme = TAILQ_FIRST(&wp->modes); struct utf8_data *ud, *uc; wchar_t wc; int i, literal; @@ -105,8 +106,13 @@ free(cause); return (CMD_RETURN_ERROR); } - if (wme != NULL && (args_has(args, 'X') || args->argc == 0)) + if (wme != NULL && (args_has(args, 'X') || args->argc == 0)) { + if (wme == NULL || wme->mode->command == NULL) { + cmdq_error(item, "not in a mode"); + return (CMD_RETURN_ERROR); + } wme->prefix = np; + } } if (args_has(args, 'X')) {