Commit: patch 9.2.0882: :bwipe crashes if WinLeave wipes all other buffers

Christian Brabandt <[email protected]> Fri, 31 Jul 2026 20:15:06 +0200
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
patch 9.2.0882: :bwipe crashes if WinLeave wipes all other buffers

Commit: https://github.com/vim/vim/commit/3e4019a082701f48bb44de0cc7a92f6a3077bd4e
Author: zeertzjq <[email protected]>
Date:   Fri Jul 31 18:07:40 2026 +0000

    patch 9.2.0882: :bwipe crashes if WinLeave wipes all other buffers
    
    Problem:  :bwipe crashes if WinLeave wipes all other buffers
              (after 9.1.2068).
    Solution: Check for NULL pointer.
    
    related: neovim/neovim#41066
    closes: #20888
    
    Signed-off-by: zeertzjq <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/buffer.c b/src/buffer.c
index 48a6bdc3d..c33c3efa0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1653,7 +1653,8 @@ do_buffer_ext(
 		buf = curbuf->b_next;
 	    else
 		buf = 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;
 	}
     }
diff --git a/src/testdir/test_buffer.vim b/src/testdir/test_buffer.vim
index 733ef6543..a8b6e8bd6 100644
--- a/src/testdir/test_buffer.vim
+++ b/src/testdir/test_buffer.vim
@@ -935,6 +935,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
diff --git a/src/version.c b/src/version.c
index 7f650d214..e7c89e818 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    882,
 /**/
     881,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wprlC-006CP3-N6%40256bit.org.