vim-patch:9.2.0882: :bwipe crashes if WinLeave wipes all other buffers (#41082)

Problem:  :bwipe crashes if WinLeave wipes all other buffers
          (after 9.1.2068).
Solution: Check for NULL pointer.

related: neovim/neovim#41066
closes: vim/vim#20888

3e4019a082
This commit is contained in:
zeertzjq
2026-08-01 07:25:28 +08:00
committed by GitHub
parent 4836ecad1f
commit f8872bccbe
2 changed files with 8 additions and 1 deletions

View File

@@ -1626,7 +1626,7 @@ static int do_buffer_ext(int action, int start, int dir, int count, int flags)
}
if (buf == NULL) { // Still no buffer, just take one
buf = curbuf->b_next != NULL ? curbuf->b_next : curbuf->b_prev;
if (bt_quickfix(buf) || (buf != curbuf && buf->b_locked_split)) {
if (bt_quickfix(buf) || (buf != NULL && buf != curbuf && buf->b_locked_split)) {
buf = NULL;
}
}

View File

@@ -937,6 +937,13 @@ func Test_split_window_in_BufLeave_from_switching_buffer()
bwipe! Xb
endfunc
func Test_wipe_other_buffers_in_WinLeave_from_bwipe()
tabnew
autocmd WinLeave * ++once 1,$-1bwipe!
" This should not crash
$bwipe!
endfunc
" Switch to a buffer whose name contains '%' via completion (#20529).
func Test_buffer_switch_to_name_with_percent()
CheckMSWindows