]> granicus.if.org Git - vim/commitdiff
patch 8.2.1760: Vim9: crash when end marker is missing v8.2.1760
authorBram Moolenaar <Bram@vim.org>
Sun, 27 Sep 2020 16:24:03 +0000 (18:24 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 27 Sep 2020 16:24:03 +0000 (18:24 +0200)
Problem:    Vim9: crash when end marker is missing. (Dhiraj Mishra)
Solution:   Check for end of function lines. (closes #7031)

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

index 0a947346a09b84fdafeb735316a76026c83c9644..eddc8c5f3431baa94911683fa7b4bb7fdc7229cc 100644 (file)
@@ -740,6 +740,22 @@ def Test_heredoc()
 
   CheckDefFailure(['var lines =<< trim END X', 'END'], 'E488:')
   CheckDefFailure(['var lines =<< trim END " comment', 'END'], 'E488:')
+
+  lines =<< trim [END]
+      def Func()
+        var&lines =<< trim END
+        x
+        x
+        x
+        x
+        x
+        x
+        x
+        x
+      enddef
+      call Func()
+  [END]
+  CheckScriptFailure(lines, 'E990:')
 enddef
 
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
index fe73a927185a893ebeec1d7779c402b19e1d4065..7205343fb2d9190b5292c5e25c96a53c4d22a198 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1760,
 /**/
     1759,
 /**/
index d505ca6709c4945575d4141396e723abb7978b2a..e4f3a906e3942f451fed4d12b8384d5665589a8a 100644 (file)
@@ -4360,7 +4360,7 @@ exarg_getline(
 
     for (;;)
     {
-       if (cctx->ctx_lnum == cctx->ctx_ufunc->uf_lines.ga_len)
+       if (cctx->ctx_lnum >= cctx->ctx_ufunc->uf_lines.ga_len - 1)
            return NULL;
        ++cctx->ctx_lnum;
        p = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum];