Mercurial > vim
changeset 28193:22c8cafe8c9c v8.2.4622
patch 8.2.4622: Vim9: crash with :execute and :finish
Commit: https://github.com/vim/vim/commit/43216611a5accd32a53fe77d4552a36f6ed30c74
Author: Bram Moolenaar <Bram@vim.org>
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 25 Mar 2022 12:30:07 +0100 |
parents | dd264fa0980c |
children | ecaeb8784e4f |
files | src/eval.c src/testdir/test_vim9_script.vim src/version.c |
diffstat | 3 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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) {
--- 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'