Patch 8.2.2464
Problem: Using freed memory if window closed in autocommand. (houyunsong)
Solution: Check the window still exists.
Files: src/ex_cmds.c, src/testdir/test_autocmd.vim
*** ../vim-8.2.2463/src/ex_cmds.c 2021-01-30 21:40:00.155043125 +0100
--- src/ex_cmds.c 2021-02-03 21:54:59.240208009 +0100
***************
*** 2768,2774 ****
did_decrement = close_buffer(oldwin, curbuf,
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE, FALSE);
! the_curwin->w_closing = FALSE;
--buf->b_locked;
#ifdef FEAT_EVAL
--- 2768,2776 ----
did_decrement = close_buffer(oldwin, curbuf,
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD, FALSE, FALSE);
! // Autocommands may have closed the window.
! if (win_valid(the_curwin))
! the_curwin->w_closing = FALSE;
--buf->b_locked;
#ifdef FEAT_EVAL
*** ../vim-8.2.2463/src/testdir/test_autocmd.vim 2021-02-03 21:23:25.319581856 +0100
--- src/testdir/test_autocmd.vim 2021-02-03 21:54:33.160327024 +0100
***************
*** 2726,2729 ****
--- 2726,2740 ----
au! BufNew
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-8.2.2463/src/version.c 2021-02-03 21:23:25.319581856 +0100
--- src/version.c 2021-02-03 21:45:54.447108033 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2464,
/**/
--
Just think of all the things we haven't thought of yet.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///