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.
8c6951fa28

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.
b7e2670b6a
This commit is contained in:
Jan Edmund Lazo
2021-05-11 22:27:21 -04:00
parent e9804aead6
commit c9195a1273
2 changed files with 14 additions and 3 deletions

View File

@@ -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);
}

View File

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