To: vim_dev@googlegroups.com Subject: Patch 8.2.3878 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3878 Problem: Vim9: debugger tries to read more lines than there are. Solution: Check the number of lines. (closes #9394) Files: src/vim9execute.c, src/testdir/test_vim9_script.vim *** ../vim-8.2.3877/src/vim9execute.c 2021-12-21 09:42:05.626265159 +0000 --- src/vim9execute.c 2021-12-23 21:12:37.732366243 +0000 *************** *** 1660,1666 **** if (end_lnum > iptr->isn_lnum) { ga_init2(&ga, sizeof(char_u *), 10); ! for (lnum = iptr->isn_lnum; lnum < end_lnum; ++lnum) { char_u *p = ((char_u **)ufunc->uf_lines.ga_data)[lnum - 1]; --- 1660,1667 ---- if (end_lnum > iptr->isn_lnum) { ga_init2(&ga, sizeof(char_u *), 10); ! 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]; *** ../vim-8.2.3877/src/testdir/test_vim9_script.vim 2021-12-20 12:24:59.381293520 +0000 --- src/testdir/test_vim9_script.vim 2021-12-23 21:13:39.160281327 +0000 *************** *** 4731,4736 **** --- 4731,4776 ---- 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\") + TermWait(buf) + WaitForAssert(() => assert_match('^>', term_getline(buf, 6))) + + term_sendkeys(buf, "cont\") + TermWait(buf) + + StopVimInTerminal(buf) + delete('XdebugFunc') + enddef + def ProfiledWithLambda() var n = 3 echo [[1, 2], [3, 4]]->filter((_, l) => l[0] == n) *** ../vim-8.2.3877/src/version.c 2021-12-22 21:40:29.350644184 +0000 --- src/version.c 2021-12-23 20:58:30.713518703 +0000 *************** *** 751,752 **** --- 751,754 ---- { /* Add new patch number below this line */ + /**/ + 3878, /**/ -- I AM THANKFUL... ...for the taxes that I pay because it means that I am employed. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///