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:
Jan Edmund Lazo
2021-02-03 18:38:46 -05:00
parent 02cda35cf7
commit da3f9778af
2 changed files with 15 additions and 1 deletions

View File

@@ -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

View File

@@ -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