diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-11 22:27:21 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-13 20:47:26 -0400 |
commit | c9195a1273159bfd227bfa9a7b407888d0d18110 (patch) | |
tree | d820617e064fc21da0711116c22abee624f5def1 | |
parent | e9804aead6adf1fb0e3d16d5544e82fc0e566890 (diff) | |
download | rneovim-c9195a1273159bfd227bfa9a7b407888d0d18110.tar.gz rneovim-c9195a1273159bfd227bfa9a7b407888d0d18110.tar.bz2 rneovim-c9195a1273159bfd227bfa9a7b407888d0d18110.zip |
vim-patch:8.2.2473: crash when leaving command line window triggers autocommand
Problem: Crash when leaving command line window triggers autocommand.
(houyunsong)
Solution: Make sure not to close the current window or buffer.
https://github.com/vim/vim/commit/8c6951fa2836a1ae3257770e7b927a9380439912
N/A patches for version.c:
vim-patch:8.2.2414: using freed memory when closing the cmdline window
Problem: Using freed memory when closing the cmdline window.
Solution: Check the window is still valid.
https://github.com/vim/vim/commit/b7e2670b6a1de02c772af5097ba24f2a15b26eec
-rw-r--r-- | src/nvim/ex_getln.c | 8 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 9 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 53571ec8da..43762e8d6b 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -6635,11 +6635,13 @@ static int open_cmdwin(void) wp = curwin; set_bufref(&bufref, curbuf); win_goto(old_curwin); - win_close(wp, true); + if (win_valid(wp) && wp != curwin) { + win_close(wp, true); + } // win_close() may have already wiped the buffer when 'bh' is - // set to 'wipe'. - if (bufref_valid(&bufref)) { + // set to 'wipe', autocommands may have closed other windows + if (bufref_valid(&bufref) && bufref.br_buf != curbuf) { close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, false); } diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index e0a04c94f8..bb84fa498e 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2000,4 +2000,13 @@ func Test_autocmd_closes_window() au! BufWinLeave endfunc +func Test_autocmd_closing_cmdwin() + au BufWinLeave * nested q + call assert_fails("norm 7q?\n", 'E855:') + + au! BufWinLeave + new + only +endfunc + " vim: shiftwidth=2 sts=2 expandtab |