forked from aniani/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.
This commit is contained in:
@@ -2768,6 +2768,8 @@ do_ecmd(
|
|||||||
did_decrement = close_buffer(oldwin, curbuf,
|
did_decrement = close_buffer(oldwin, curbuf,
|
||||||
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE, FALSE);
|
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE, FALSE);
|
||||||
|
|
||||||
|
// Autocommands may have closed the window.
|
||||||
|
if (win_valid(the_curwin))
|
||||||
the_curwin->w_closing = FALSE;
|
the_curwin->w_closing = FALSE;
|
||||||
--buf->b_locked;
|
--buf->b_locked;
|
||||||
|
|
||||||
|
@@ -2726,4 +2726,15 @@ func Test_BufNew_arglocal()
|
|||||||
au! BufNew
|
au! BufNew
|
||||||
endfunc
|
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
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2464,
|
||||||
/**/
|
/**/
|
||||||
2463,
|
2463,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user