Skip to content

Commit f144a3f

Browse files
committed
patch 8.0.0816: crash when using invalid buffer number
Problem: Crash when using invalid buffer number. Solution: Check for NULL buffer. (Yasuhiro Matsumoto, closes #1899)
1 parent 43c007f commit f144a3f

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/terminal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ term_get_buf(typval_T *argvars)
16861686
++emsg_off;
16871687
buf = get_buf_tv(&argvars[0], FALSE);
16881688
--emsg_off;
1689-
if (buf->b_term == NULL)
1689+
if (buf == NULL || buf->b_term == NULL)
16901690
return NULL;
16911691
return buf;
16921692
}

src/testdir/test_terminal.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ func Test_terminal_scrape()
5454
call assert_equal(1, len(termlist))
5555
call assert_equal(buf, termlist[0])
5656

57+
" Nothing happens with invalid buffer number
58+
call term_wait(1234)
59+
5760
call term_wait(buf)
5861
call Check_123(buf)
5962

@@ -64,4 +67,5 @@ func Test_terminal_scrape()
6467
call Check_123(buf)
6568

6669
exe buf . 'bwipe'
70+
call delete('Xtext')
6771
endfunc

src/version.c

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

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
816,
772774
/**/
773775
815,
774776
/**/

0 commit comments

Comments
 (0)