]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0882: :bwipe crashes if WinLeave wipes all other buffers v9.2.0882
authorzeertzjq <zeertzjq@outlook.com>
Fri, 31 Jul 2026 18:07:40 +0000 (18:07 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 31 Jul 2026 18:07:40 +0000 (18:07 +0000)
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 <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/buffer.c
src/testdir/test_buffer.vim
src/version.c

index 48a6bdc3db83a3ca394a3f5db164a146b6c01999..c33c3efa0f55f3c8f169897429c4f4c5ae850b7e 100644 (file)
@@ -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;
        }
     }
index 733ef6543492aa473b68866dd759daa00d9728ca..a8b6e8bd6983c7cd2bec1fb7f41ec1cc3f4368d3 100644 (file)
@@ -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
index 7f650d214ab89df63989a449f00234923ed5046b..e7c89e81862dccb95655a119bd940a670a343859 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    882,
 /**/
     881,
 /**/