nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 103dd06347bcecbaa807c438864eb747d464d745
parent 1d4c1e0bfc732acccae42d85f541f0220e152387
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sat, 16 Jul 2016 22:11:14 +0200

input: don't crash when the window is resized during verbatim input

Instead of referring to a window that might have been deleted by a
resize, just turn the keypad back on for the two windows from which
input might have been requested.

Also: don't insert KEY_WINCH as the verbatim keystroke.

This fixes https://savannah.gnu.org/bugs/?48532.

Diffstat:
Msrc/winio.c | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git 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