]> granicus.if.org Git - vim/commitdiff
patch 8.2.4622: Vim9: crash with :execute and :finish v8.2.4622
authorBram Moolenaar <Bram@vim.org>
Fri, 25 Mar 2022 11:16:28 +0000 (11:16 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 25 Mar 2022 11:16:28 +0000 (11:16 +0000)
Problem:    Vim9: Crash with :execute and :finish. (Sergey Vlasov)
Solution:   Check for NULL. (closes #10011)

src/eval.c
src/testdir/test_vim9_script.vim
src/version.c

index a963a15c01eaefc37d1dcd7df90342c55cd88f04..4447186e228d3d74e1d3ea702b37608d28104dbe 100644 (file)
@@ -2144,7 +2144,8 @@ getline_peek_skip_comments(evalarg_T *evalarg)
        p = skipwhite(next);
        if (*p != NUL && !vim9_comment_start(p))
            return next;
-       (void)eval_next_line(evalarg);
+       if (eval_next_line(evalarg) == NULL)
+           break;
     }
     return NULL;
 }
@@ -2199,6 +2200,9 @@ eval_next_line(evalarg_T *evalarg)
                                                           GETLINE_CONCAT_ALL);
     else
        line = next_line_from_context(evalarg->eval_cctx, TRUE);
+    if (line == NULL)
+       return NULL;
+
     ++evalarg->eval_break_count;
     if (gap->ga_itemsize > 0 && ga_grow(gap, 1) == OK)
     {
index b1b63d2d6eedf651067c95329c4ed2efaf8a9bed..71cef1ee9e6016ac4b7769938521990bc8d801a1 100644 (file)
@@ -1830,6 +1830,24 @@ def Test_execute_cmd_vimscript()
   v9.CheckScriptSuccess(lines)
 enddef
 
+def Test_execute_finish()
+  # the empty lines are relevant here
+  var lines =<< trim END
+      vim9script
+
+      var vname = "g:hello"
+
+      if exists(vname) | finish | endif | execute vname '= "world"'
+
+      assert_equal('world', g:hello)
+
+      if exists(vname) | finish | endif | execute vname '= "world"'
+
+      assert_report('should not be reached')
+  END
+  v9.CheckScriptSuccess(lines)
+enddef
+
 def Test_echo_cmd()
   echo 'some' # comment
   echon 'thing'
index bcb70e8d4d8d30efc44b6dd5fd9249b9b20f61d7..d6edc46e89708fdde1fcecaa4e4f23c59e6281e0 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4622,
 /**/
     4621,
 /**/