diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-12 19:16:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 19:16:47 +0800 |
commit | 7e1e906738ae8cf2d38ded4be3bef50d72b7c2a7 (patch) | |
tree | 7ced47de808516f092020d983504c84b41c90e8d /src/nvim/testdir | |
parent | dbd5242d8e10db4ed077547755f0d84aa8261cb5 (diff) | |
download | rneovim-7e1e906738ae8cf2d38ded4be3bef50d72b7c2a7.tar.gz rneovim-7e1e906738ae8cf2d38ded4be3bef50d72b7c2a7.tar.bz2 rneovim-7e1e906738ae8cf2d38ded4be3bef50d72b7c2a7.zip |
vim-patch:8.2.4739: accessing freed memory after WinScrolled autocmd event (#18090)
Problem: Accessing freed memory after WinScrolled autocmd event.
Solution: Check the window pointer is still valid. (closes vim/vim#10156)
Remove the argument from may_trigger_winscrolled().
https://github.com/vim/vim/commit/d58862d18f091d3c14fa3647e724ef7eea1ecefa
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 4b4f6ad3d3..228145ec4d 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -265,17 +265,17 @@ func Test_WinScrolled() CheckRunVimInTerminal let lines =<< trim END - set nowrap scrolloff=0 - for ii in range(1, 18) - call setline(ii, repeat(nr2char(96 + ii), ii * 2)) - endfor - let win_id = win_getid() - let g:matched = v:false - execute 'au WinScrolled' win_id 'let g:matched = v:true' - let g:scrolled = 0 - au WinScrolled * let g:scrolled += 1 - au WinScrolled * let g:amatch = str2nr(expand('<amatch>')) - au WinScrolled * let g:afile = str2nr(expand('<afile>')) + set nowrap scrolloff=0 + for ii in range(1, 18) + call setline(ii, repeat(nr2char(96 + ii), ii * 2)) + endfor + let win_id = win_getid() + let g:matched = v:false + execute 'au WinScrolled' win_id 'let g:matched = v:true' + let g:scrolled = 0 + au WinScrolled * let g:scrolled += 1 + au WinScrolled * let g:amatch = str2nr(expand('<amatch>')) + au WinScrolled * let g:afile = str2nr(expand('<afile>')) END call writefile(lines, 'Xtest_winscrolled') let buf = RunVimInTerminal('-S Xtest_winscrolled', {'rows': 6}) @@ -315,6 +315,30 @@ func Test_WinScrolled() call delete('Xtest_winscrolled') endfunc +func Test_WinScrolled_close_curwin() + CheckRunVimInTerminal + + let lines =<< trim END + set nowrap scrolloff=0 + call setline(1, ['aaa', 'bbb']) + vsplit + au WinScrolled * close + au VimLeave * call writefile(['123456'], 'Xtestout') + END + call writefile(lines, 'Xtest_winscrolled_close_curwin') + let buf = RunVimInTerminal('-S Xtest_winscrolled_close_curwin', {'rows': 6}) + + " This was using freed memory + call term_sendkeys(buf, "\<C-E>") + call TermWait(buf) + call StopVimInTerminal(buf) + + call assert_equal(['123456'], readfile('Xtestout')) + + call delete('Xtest_winscrolled_close_curwin') + call delete('Xtestout') +endfunc + func Test_WinClosed() " Test that the pattern is matched against the closed window's ID, and both " <amatch> and <afile> are set to it. |