From acd4c5e914f8a06745624ba585f3d06d5faf4ddd Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 22 Jun 2020 19:39:03 +0200 Subject: [PATCH] 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. --- src/testdir/test_vim9_func.vim | 11 +++++++++++ src/version.c | 2 ++ src/vim9compile.c | 5 ++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim index 6a9d4ba368..fbe73f7dcf 100644 --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -837,5 +837,16 @@ def Test_sort_return_type() res = [1, 2, 3]->sort() enddef +def Line_continuation_in_def(dir: string = ''): string + let path: string = empty(dir) + \ ? 'empty' + \ : 'full' + return path +enddef + +def Test_line_continuation_in_def() + assert_equal('full', Line_continuation_in_def('.')) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index 42c03d0922..43b1010809 100644 --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1037, /**/ 1036, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index 033a8d9ed9..30e447f759 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2402,8 +2402,11 @@ peek_next_line(cctx_T *cctx) while (++lnum < cctx->ctx_ufunc->uf_lines.ga_len) { char_u *line = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[lnum]; - char_u *p = skipwhite(line); + char_u *p; + if (line == NULL) + break; + p = skipwhite(line); if (*p != NUL && !comment_start(p)) return p; }