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().
d58862d18f
This commit is contained in:
zeertzjq
2022-04-12 19:16:47 +08:00
committed by GitHub
parent dbd5242d8e
commit 7e1e906738
5 changed files with 59 additions and 20 deletions

View File

@@ -6,12 +6,14 @@ local eval = helpers.eval
local command = helpers.command
local feed = helpers.feed
local meths = helpers.meths
local assert_alive = helpers.assert_alive
before_each(clear)
describe('WinScrolled', function()
local win_id
before_each(function()
clear()
win_id = meths.get_current_win().id
command(string.format('autocmd WinScrolled %d let g:matched = v:true', win_id))
command('let g:scrolled = 0')
@@ -72,3 +74,12 @@ describe('WinScrolled', function()
eq(1, eval('g:scrolled'))
end)
end)
it('closing window in WinScrolled does not cause use-after-free #13265', function()
local lines = {'aaa', 'bbb'}
meths.buf_set_lines(0, 0, -1, true, lines)
command('vsplit')
command('autocmd WinScrolled * close')
feed('<C-E>')
assert_alive()
end)