diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-03-27 08:57:57 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-03-27 10:01:07 +0800 |
commit | f4f18a983305d3cf8a6028333e9b99e86283032b (patch) | |
tree | 93272007351ed4c95eb46910e14ba69b8f4e6b7c /src/nvim/buffer.c | |
parent | a490db5ba819218e9188cbb51d885dbf3a194000 (diff) | |
download | rneovim-f4f18a983305d3cf8a6028333e9b99e86283032b.tar.gz rneovim-f4f18a983305d3cf8a6028333e9b99e86283032b.tar.bz2 rneovim-f4f18a983305d3cf8a6028333e9b99e86283032b.zip |
vim-patch:8.2.4631: crash when switching window in BufWipeout autocommand
Problem: Crash when switching window in BufWipeout autocommand.
Solution: Put any buffer in the window to avoid it being NULL.
(closes vim/vim#10024)
https://github.com/vim/vim/commit/347538fad0c503249ebdedd5884c2081257c9f61
win_init_empty() cannot be made static because it is used in autocmd.c
Diffstat (limited to 'src/nvim/buffer.c')
-rw-r--r-- | src/nvim/buffer.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 4ca752e747..bf592a626d 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -590,6 +590,10 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last) // Remove the buffer from the list. if (wipe_buf) { + // Do not wipe out the buffer if it is used in a window. + if (buf->b_nwindows > 0) { + return false; + } if (buf->b_sfname != buf->b_ffname) { XFREE_CLEAR(buf->b_sfname); } else { |