mirror of
https://github.com/neovim/neovim.git
synced 2026-08-01 05:09:08 +00:00
fix(window): avoid UAF in close_windows (#40853)
(cherry picked from commit a787a31490)
This commit is contained in:
committed by
github-actions[bot]
parent
6cb9334aa0
commit
37d7b11bc1
@@ -2632,7 +2632,7 @@ void close_windows(buf_T *buf, bool keep_curwin)
|
||||
}
|
||||
if (!win_close_othertab(wp, false, tp, false)) {
|
||||
// If closing the window fails give up, to avoid looping forever.
|
||||
break;
|
||||
goto theend;
|
||||
}
|
||||
|
||||
// Start all over, the tab page may be closed and
|
||||
|
||||
@@ -2461,6 +2461,20 @@ describe('api/buf', function()
|
||||
ok(not api.nvim_buf_is_loaded(b))
|
||||
ok(api.nvim_buf_is_valid(b))
|
||||
end)
|
||||
|
||||
it('does not crash if WinClosed closes the next tabpage #40852', function()
|
||||
exec_lua(function()
|
||||
vim.cmd.tabnew()
|
||||
vim.api.nvim_create_autocmd('WinClosed', {
|
||||
callback = function()
|
||||
pcall(vim.api.nvim_win_close, 0, true)
|
||||
end,
|
||||
})
|
||||
local bufs = vim.api.nvim_list_bufs()
|
||||
vim.api.nvim_buf_delete(bufs[#bufs - 1], { force = true })
|
||||
end)
|
||||
assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('nvim_buf_get_mark', function()
|
||||
|
||||
Reference in New Issue
Block a user