mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
vim-patch:8.2.2464: using freed memory if window closed in autocommand
Problem: Using freed memory if window closed in autocommand. (houyunsong)
Solution: Check the window still exists.
8ab375706e
This commit is contained in:
@@ -2416,7 +2416,10 @@ int do_ecmd(
|
||||
(flags & ECMD_HIDE) || curbuf->terminal ? 0 : DOBUF_UNLOAD,
|
||||
false);
|
||||
|
||||
the_curwin->w_closing = false;
|
||||
// Autocommands may have closed the window.
|
||||
if (win_valid(the_curwin)) {
|
||||
the_curwin->w_closing = false;
|
||||
}
|
||||
buf->b_locked--;
|
||||
|
||||
// autocmds may abort script processing
|
||||
|
@@ -1939,4 +1939,15 @@ func Test_autocmd_window()
|
||||
%bw!
|
||||
endfunc
|
||||
|
||||
func Test_autocmd_closes_window()
|
||||
au BufNew,BufWinLeave * e %e
|
||||
file yyy
|
||||
au BufNew,BufWinLeave * ball
|
||||
call assert_fails('n xxx', 'E143:')
|
||||
|
||||
bwipe %
|
||||
au! BufNew
|
||||
au! BufWinLeave
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user