# HG changeset patch # User Bram Moolenaar # Date 1648207807 -3600 # Node ID 22c8cafe8c9cecf629ec79dd06804a1362cdcfe7 # Parent dd264fa0980c44c7795b8d1c37376965ac3f4d8e patch 8.2.4622: Vim9: crash with :execute and :finish Commit: https://github.com/vim/vim/commit/43216611a5accd32a53fe77d4552a36f6ed30c74 Author: Bram Moolenaar Date: Fri Mar 25 11:16:28 2022 +0000 patch 8.2.4622: Vim9: crash with :execute and :finish Problem: Vim9: Crash with :execute and :finish. (Sergey Vlasov) Solution: Check for NULL. (closes https://github.com/vim/vim/issues/10011) diff --git a/src/eval.c b/src/eval.c --- a/src/eval.c +++ b/src/eval.c @@ -2144,7 +2144,8 @@ getline_peek_skip_comments(evalarg_T *ev 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 --- 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 --- 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,