aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-06-06 19:59:17 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-06-06 22:43:48 -0400
commitbb4e0deaf924490f792433becbe0629fe0ce5b4e (patch)
treef9e8a7bdeed8289eeff0ab2aad5adc598751163c
parent7d345a7294a24e8270bf608dd87d1ebd8c897432 (diff)
downloadrneovim-bb4e0deaf924490f792433becbe0629fe0ce5b4e.tar.gz
rneovim-bb4e0deaf924490f792433becbe0629fe0ce5b4e.tar.bz2
rneovim-bb4e0deaf924490f792433becbe0629fe0ce5b4e.zip
vim-patch:8.1.0060: crash when autocommands delete the current buffer
Problem: Crash when autocommands delete the current buffer. (Dominique Pelle) Solution: Check that autocommands don't change the buffer. https://github.com/vim/vim/commit/600323b4ef51a58a8e800d8ca469383a3c911db7
-rw-r--r--src/nvim/quickfix.c6
-rw-r--r--src/nvim/testdir/test_quickfix.vim12
2 files changed, 18 insertions, 0 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index b70e881d33..03f909f634 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -5255,8 +5255,14 @@ void ex_cbuffer(exarg_T *eap)
qf_list_changed(qi, qi->qf_curlist);
}
if (au_name != NULL) {
+ const buf_T *const curbuf_old = curbuf;
apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name,
curbuf->b_fname, true, curbuf);
+ if (curbuf != curbuf_old) {
+ // Autocommands changed buffer, don't jump now, "qi" may
+ // be invalid.
+ res = 0;
+ }
}
if (res > 0 && (eap->cmdidx == CMD_cbuffer
|| eap->cmdidx == CMD_lbuffer)) {
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 12cd07a772..16fb86ea08 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -3360,3 +3360,15 @@ func Test_vimgrep_autocmd()
call delete('Xtest2.txt')
call setqflist([], 'f')
endfunc
+
+func Test_lbuffer_with_bwipe()
+ new
+ new
+ augroup nasty
+ au * * bwipe
+ augroup END
+ lbuffer
+ augroup nasty
+ au!
+ augroup END
+endfunc