diff --git a/src/winio.c b/src/winio.c index 5df57ae7..c5e5cce0 100644 --- a/src/winio.c +++ b/src/winio.c @@ -1375,8 +1375,12 @@ int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) * keypad back on if necessary now that we're done. */ if (ISSET(PRESERVE)) enable_flow_control(); - if (!ISSET(REBIND_KEYPAD)) - keypad(win, TRUE); + /* Use the global window pointers, because a resize may have freed + * the data that the win parameter points to. */ + if (!ISSET(REBIND_KEYPAD)) { + keypad(edit, TRUE); + keypad(bottomwin, TRUE); + } return retval; } @@ -1393,6 +1397,13 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len) while ((kbinput = get_input(win, 1)) == NULL) ; + /* When the window was resized, abort and return nothing. */ + if (*kbinput == KEY_WINCH) { + *kbinput_len = 0; + free(kbinput); + return NULL; + } + #ifdef ENABLE_UTF8 if (using_utf8()) { /* Check whether the first keystroke is a valid hexadecimal