Skip to content

Commit

Permalink
patch 8.2.3878: Vim9: debugger tries to read more lines than there are
Browse files Browse the repository at this point in the history
Problem:    Vim9: debugger tries to read more lines than there are.
Solution:   Check the number of lines. (closes #9394)
  • Loading branch information
brammool committed Dec 23, 2021
1 parent 28fbbea commit 310091d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/testdir/test_vim9_script.vim
Expand Up @@ -4731,6 +4731,46 @@ def Run_Test_debug_with_lambda()
delete('XdebugFunc')
enddef

func Test_debug_running_out_of_lines()
CheckRunVimInTerminal

" call indirectly to avoid compilation error for missing functions
call Run_Test_debug_running_out_of_lines()
endfunc

def Run_Test_debug_running_out_of_lines()
var lines =<< trim END
vim9script
def Crash()
#
#
#
#
#
#
#
if true
#
endif
enddef
breakadd func Crash
Crash()
END
writefile(lines, 'XdebugFunc')
var buf = RunVimInTerminal('-S XdebugFunc', {rows: 6, wait_for_ruler: 0})
WaitForAssert(() => assert_match('^>', term_getline(buf, 6)))

term_sendkeys(buf, "next\<CR>")
TermWait(buf)
WaitForAssert(() => assert_match('^>', term_getline(buf, 6)))

term_sendkeys(buf, "cont\<CR>")
TermWait(buf)

StopVimInTerminal(buf)
delete('XdebugFunc')
enddef

def ProfiledWithLambda()
var n = 3
echo [[1, 2], [3, 4]]->filter((_, l) => l[0] == n)
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -749,6 +749,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3878,
/**/
3877,
/**/
Expand Down
3 changes: 2 additions & 1 deletion src/vim9execute.c
Expand Up @@ -1660,7 +1660,8 @@ handle_debug(isn_T *iptr, ectx_T *ectx)
if (end_lnum > iptr->isn_lnum)
{
ga_init2(&ga, sizeof(char_u *), 10);
for (lnum = iptr->isn_lnum; lnum < end_lnum; ++lnum)
for (lnum = iptr->isn_lnum; lnum < end_lnum
&& lnum <= ufunc->uf_lines.ga_len; ++lnum)
{
char_u *p = ((char_u **)ufunc->uf_lines.ga_data)[lnum - 1];

Expand Down

0 comments on commit 310091d

Please sign in to comment.