summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-06-16 22:16:47 +0200
committerBram Moolenaar <Bram@vim.org>2018-06-16 22:16:47 +0200
commit600323b4ef51a58a8e800d8ca469383a3c911db7 (patch)
tree46fb6deba8ab76a4a4b0bd50e814cec08ac05cf7
parentbc5020aa4d7ef4aea88395eff858f74fc881eab9 (diff)
patch 8.1.0060: crash when autocommands delete the current bufferv8.1.0060
Problem: Crash when autocommands delete the current buffer. (Dominique Pelle) Solution: Check that autocommands don't change the buffer.
-rw-r--r--src/quickfix.c8
-rw-r--r--src/testdir/test_quickfix.vim12
-rw-r--r--src/version.c2
3 files changed, 22 insertions, 0 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index 1b281ceab2..031c6e7a6b 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -6272,8 +6272,16 @@ ex_cbuffer(exarg_T *eap)
if (res >= 0)
qf_list_changed(qi, qi->qf_curlist);
if (au_name != NULL)
+ {
+ buf_T *curbuf_old = curbuf;
+
apply_autocmds(EVENT_QUICKFIXCMDPOST, 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))
qf_jump(qi, 0, 0, eap->forceit); /* display first error */
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index c3850ce1f4..eade52f42d 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -3350,3 +3350,15 @@ func Test_qftitle()
call assert_equal('Errors', w:quickfix_title)
cclose
endfunc
+
+func Test_lbuffer_with_bwipe()
+ new
+ new
+ augroup nasty
+ au * * bwipe
+ augroup END
+ lbuffer
+ augroup nasty
+ au!
+ augroup END
+endfunc
diff --git a/src/version.c b/src/version.c
index 68b4c26b86..6406e6cd87 100644
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 60,
+/**/
59,
/**/
58,