diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-03-25 11:16:28 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-03-25 11:16:28 +0000 |
commit | 43216611a5accd32a53fe77d4552a36f6ed30c74 (patch) | |
tree | d82710661e02df5456ef7ec45ca9cba2dcd3037f | |
parent | 9dd42a631162a8561bd7c4b0e89afd21f7994d8c (diff) | |
download | vim-git-43216611a5accd32a53fe77d4552a36f6ed30c74.tar.gz |
patch 8.2.4622: Vim9: crash with :execute and :finishv8.2.4622
Problem: Vim9: Crash with :execute and :finish. (Sergey Vlasov)
Solution: Check for NULL. (closes #10011)
-rw-r--r-- | src/eval.c | 6 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 18 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 25 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c index a963a15c0..4447186e2 100644 --- a/src/eval.c +++ b/src/eval.c @@ -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) { diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index b1b63d2d6..71cef1ee9 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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' diff --git a/src/version.c b/src/version.c index bcb70e8d4..d6edc46e8 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4622, +/**/ 4621, /**/ 4620, |