]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.1037: Vim9: crash when using line continuation inside :def v8.2.1037
authorBram Moolenaar <Bram@vim.org>
Mon, 22 Jun 2020 17:39:03 +0000 (19:39 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 22 Jun 2020 17:39:03 +0000 (19:39 +0200)
Problem:    Vim9: crash when using line continuation inside :def.
Solution:   Check for no more lines available.

src/testdir/test_vim9_func.vim
src/version.c
src/vim9compile.c

index 6a9d4ba3681844883ae2285da42496e70dc4a7d8..fbe73f7dcfe4bca236319ba128f7b4fa9bc23c0d 100644 (file)
@@ -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
index 42c03d09222565788819dee91d503c0f2548c19d..43b101080926dc73869de2c7718bc5d869282413 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1037,
 /**/
     1036,
 /**/
index 033a8d9ed92384d05525a4196ee3fb8bf1e51749..30e447f7599db0f2f97dd8e8f6ebcf7689e5390f 100644 (file)
@@ -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;
     }