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.
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 71f8d2d..b1a235c 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -2726,4 +2726,15 @@
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