Skip to content

Commit acd4c5e

Browse files
committed
patch 8.2.1037: Vim9: crash when using line continuation inside :def
Problem: Vim9: crash when using line continuation inside :def. Solution: Check for no more lines available.
1 parent 373c651 commit acd4c5e

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/testdir/test_vim9_func.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,5 +837,16 @@ def Test_sort_return_type()
837837
res = [1, 2, 3]->sort()
838838
enddef
839839

840+
def Line_continuation_in_def(dir: string = ''): string
841+
let path: string = empty(dir)
842+
\ ? 'empty'
843+
\ : 'full'
844+
return path
845+
enddef
846+
847+
def Test_line_continuation_in_def()
848+
assert_equal('full', Line_continuation_in_def('.'))
849+
enddef
850+
840851

841852
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

src/version.c

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

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1037,
757759
/**/
758760
1036,
759761
/**/

src/vim9compile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2402,8 +2402,11 @@ peek_next_line(cctx_T *cctx)
24022402
while (++lnum < cctx->ctx_ufunc->uf_lines.ga_len)
24032403
{
24042404
char_u *line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[lnum];
2405-
char_u *p = skipwhite(line);
2405+
char_u *p;
24062406

2407+
if (line == NULL)
2408+
break;
2409+
p = skipwhite(line);
24072410
if (*p != NUL && !comment_start(p))
24082411
return p;
24092412
}

0 commit comments

Comments
 (0)