Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
patch 9.0.0360: crash when invalid line number on :for is ignored
Problem:    Crash when invalid line number on :for is ignored.
Solution:   Do not check breakpoint for non-existing line.
  • Loading branch information
brammool committed Sep 2, 2022
1 parent 8deb2b3 commit 35d21c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ex_docmd.c
Expand Up @@ -1068,7 +1068,7 @@ do_cmdline(

// Check for the next breakpoint at or after the ":while"
// or ":for".
if (breakpoint != NULL)
if (breakpoint != NULL && lines_ga.ga_len > current_line)
{
*breakpoint = dbg_find_breakpoint(
getline_equal(fgetline, cookie, getsourceline),
Expand Down
13 changes: 13 additions & 0 deletions src/testdir/test_eval_stuff.vim
@@ -1,6 +1,7 @@
" Tests for various eval things.

source view_util.vim
source shared.vim

function s:foo() abort
try
Expand Down Expand Up @@ -87,6 +88,18 @@ func Test_for_over_null_string()
let &enc = save_enc
endfunc

func Test_for_invalid_line_count()
let lines =<< trim END
111111111111111111111111 for line in ['one']
endfor
END
call writefile(lines, 'XinvalidFor')
" only test that this doesn't crash
call RunVim([], [], '-u NONE -e -s -S XinvalidFor -c qa')

call delete('XinvalidFor')
endfunc

func Test_readfile_binary()
new
call setline(1, ['one', 'two', 'three'])
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -707,6 +707,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
360,
/**/
359,
/**/
Expand Down

0 comments on commit 35d21c6

Please sign in to comment.