]> granicus.if.org Git - vim/commitdiff
patch 8.2.1985: crash when closing terminal popup with <Cmd> mapping v8.2.1985
authorBram Moolenaar <Bram@vim.org>
Sat, 14 Nov 2020 19:21:55 +0000 (20:21 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 14 Nov 2020 19:21:55 +0000 (20:21 +0100)
Problem:    Crash when closing terminal popup with <Cmd> mapping.
Solution:   Check b_term is not NULL. (closes #7294)

src/terminal.c
src/testdir/test_terminal.vim
src/version.c

index 4e2ff14dda6fe91e1f29e739e345aedb8cd85099..7f38bf75ca00cc13cd67567af8347d99de89ba9f 100644 (file)
@@ -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
index 137a8a6056c7081f2065360ff7b062f26fd834fc..8d68ceb5b4377e4384140f00f88a5bb02bf7b9d3 100644 (file)
@@ -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 <F3> <Cmd>call popup_close(s:winid)<CR>
+  call feedkeys("\<F3>", 'xt')
+
+  tunmap  <F3>
+  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)))
index 8d21a4aab4d084f061751f8893fa6d84913735da..8174386fecde80d0ea3b90aae5ebff89cd1a1ceb 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1985,
 /**/
     1984,
 /**/