# HG changeset patch # User Bram Moolenaar # Date 1605382203 -3600 # Node ID b952e0a3af2fdffbbf7adf91fb93b305e8c49f9b # Parent ef23eb1c4b792e094f9ac9ef677af67aba54db25 patch 8.2.1985: crash when closing terminal popup with mapping Commit: https://github.com/vim/vim/commit/02764713a715c55e316e2bef5c9ade2fb767ee78 Author: Bram Moolenaar Date: Sat Nov 14 20:21:55 2020 +0100 patch 8.2.1985: crash when closing terminal popup with mapping Problem: Crash when closing terminal popup with mapping. Solution: Check b_term is not NULL. (closes https://github.com/vim/vim/issues/7294) diff --git a/src/terminal.c b/src/terminal.c --- a/src/terminal.c +++ b/src/terminal.c @@ -2527,7 +2527,7 @@ terminal_loop(int blocking) while (blocking || vpeekc_nomap() != NUL) { #ifdef FEAT_GUI - if (!curbuf->b_term->tl_system) + if (curbuf->b_term != NULL && !curbuf->b_term->tl_system) #endif // TODO: skip screen update when handling a sequence of keys. // Repeat redrawing in case a message is received while redrawing. @@ -2542,8 +2542,6 @@ terminal_loop(int blocking) restore_cursor = TRUE; raw_c = term_vgetc(); -if (raw_c > 0) - ch_log(NULL, "terminal_loop() got %d", raw_c); if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term) { // Job finished while waiting for a character. Push back the diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -1225,6 +1225,18 @@ func Test_open_term_from_cmd() call delete('Xopenterm') endfunc +func Test_terminal_popup_with_cmd() + " this was crashing + let buf = term_start(&shell, #{hidden: v:true}) + let s:winid = popup_create(buf, {}) + tnoremap call popup_close(s:winid) + call feedkeys("\", 'xt') + + tunmap + exe 'bwipe! ' .. buf + unlet s:winid +endfunc + func Check_dump01(off) call assert_equal('one two three four five', trim(getline(a:off + 1))) call assert_equal('~ Select Word', trim(getline(a:off + 7))) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1985, +/**/ 1984, /**/ 1983,