Skip to content

Commit 4321661

Browse files
committed
patch 8.2.4622: Vim9: crash with :execute and :finish
Problem: Vim9: Crash with :execute and :finish. (Sergey Vlasov) Solution: Check for NULL. (closes #10011)
1 parent 9dd42a6 commit 4321661

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/eval.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,8 @@ getline_peek_skip_comments(evalarg_T *evalarg)
21442144
p = skipwhite(next);
21452145
if (*p != NUL && !vim9_comment_start(p))
21462146
return next;
2147-
(void)eval_next_line(evalarg);
2147+
if (eval_next_line(evalarg) == NULL)
2148+
break;
21482149
}
21492150
return NULL;
21502151
}
@@ -2199,6 +2200,9 @@ eval_next_line(evalarg_T *evalarg)
21992200
GETLINE_CONCAT_ALL);
22002201
else
22012202
line = next_line_from_context(evalarg->eval_cctx, TRUE);
2203+
if (line == NULL)
2204+
return NULL;
2205+
22022206
++evalarg->eval_break_count;
22032207
if (gap->ga_itemsize > 0 && ga_grow(gap, 1) == OK)
22042208
{

src/testdir/test_vim9_script.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,24 @@ def Test_execute_cmd_vimscript()
18301830
v9.CheckScriptSuccess(lines)
18311831
enddef
18321832

1833+
def Test_execute_finish()
1834+
# the empty lines are relevant here
1835+
var lines =<< trim END
1836+
vim9script
1837+
1838+
var vname = "g:hello"
1839+
1840+
if exists(vname) | finish | endif | execute vname '= "world"'
1841+
1842+
assert_equal('world', g:hello)
1843+
1844+
if exists(vname) | finish | endif | execute vname '= "world"'
1845+
1846+
assert_report('should not be reached')
1847+
END
1848+
v9.CheckScriptSuccess(lines)
1849+
enddef
1850+
18331851
def Test_echo_cmd()
18341852
echo 'some' # comment
18351853
echon 'thing'

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
4622,
753755
/**/
754756
4621,
755757
/**/

0 commit comments

Comments
 (0)