diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-23 21:14:37 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-23 21:14:37 +0000 |
commit | 310091d20f26f6472fefc31e19004684f3d640bf (patch) | |
tree | 1dec60ebe330d47eac374e22c2168cb9c06d038d | |
parent | 28fbbeac7046f33db350294908eecb380042d553 (diff) | |
download | vim-git-310091d20f26f6472fefc31e19004684f3d640bf.tar.gz |
patch 8.2.3878: Vim9: debugger tries to read more lines than there arev8.2.3878
Problem: Vim9: debugger tries to read more lines than there are.
Solution: Check the number of lines. (closes #9394)
-rw-r--r-- | src/testdir/test_vim9_script.vim | 40 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9execute.c | 3 |
3 files changed, 44 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index fe985de35..dcfe88864 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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) diff --git a/src/version.c b/src/version.c index e310f7675..e9d77a924 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3878, +/**/ 3877, /**/ 3876, diff --git a/src/vim9execute.c b/src/vim9execute.c index 74851121b..72cbb9044 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -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]; |