Skip to content

Commit 0276471

Browse files
committed
patch 8.2.1985: crash when closing terminal popup with <Cmd> mapping
Problem: Crash when closing terminal popup with <Cmd> mapping. Solution: Check b_term is not NULL. (closes #7294)
1 parent 33aecb1 commit 0276471

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/terminal.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,7 @@ terminal_loop(int blocking)
25272527
while (blocking || vpeekc_nomap() != NUL)
25282528
{
25292529
#ifdef FEAT_GUI
2530-
if (!curbuf->b_term->tl_system)
2530+
if (curbuf->b_term != NULL && !curbuf->b_term->tl_system)
25312531
#endif
25322532
// TODO: skip screen update when handling a sequence of keys.
25332533
// Repeat redrawing in case a message is received while redrawing.
@@ -2542,8 +2542,6 @@ terminal_loop(int blocking)
25422542
restore_cursor = TRUE;
25432543

25442544
raw_c = term_vgetc();
2545-
if (raw_c > 0)
2546-
ch_log(NULL, "terminal_loop() got %d", raw_c);
25472545
if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term)
25482546
{
25492547
// Job finished while waiting for a character. Push back the

src/testdir/test_terminal.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,18 @@ func Test_open_term_from_cmd()
12251225
call delete('Xopenterm')
12261226
endfunc
12271227

1228+
func Test_terminal_popup_with_cmd()
1229+
" this was crashing
1230+
let buf = term_start(&shell, #{hidden: v:true})
1231+
let s:winid = popup_create(buf, {})
1232+
tnoremap <F3> <Cmd>call popup_close(s:winid)<CR>
1233+
call feedkeys("\<F3>", 'xt')
1234+
1235+
tunmap <F3>
1236+
exe 'bwipe! ' .. buf
1237+
unlet s:winid
1238+
endfunc
1239+
12281240
func Check_dump01(off)
12291241
call assert_equal('one two three four five', trim(getline(a:off + 1)))
12301242
call assert_equal('~ Select Word', trim(getline(a:off + 7)))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1985,
753755
/**/
754756
1984,
755757
/**/

0 commit comments

Comments
 (0)