Skip to content

Commit 600323b

Browse files
committed
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.
1 parent bc5020a commit 600323b

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/quickfix.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6272,8 +6272,16 @@ ex_cbuffer(exarg_T *eap)
62726272
if (res >= 0)
62736273
qf_list_changed(qi, qi->qf_curlist);
62746274
if (au_name != NULL)
6275+
{
6276+
buf_T *curbuf_old = curbuf;
6277+
62756278
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
62766279
curbuf->b_fname, TRUE, curbuf);
6280+
if (curbuf != curbuf_old)
6281+
// Autocommands changed buffer, don't jump now, "qi" may
6282+
// be invalid.
6283+
res = 0;
6284+
}
62776285
if (res > 0 && (eap->cmdidx == CMD_cbuffer ||
62786286
eap->cmdidx == CMD_lbuffer))
62796287
qf_jump(qi, 0, 0, eap->forceit); /* display first error */

src/testdir/test_quickfix.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,3 +3350,15 @@ func Test_qftitle()
33503350
call assert_equal('Errors', w:quickfix_title)
33513351
cclose
33523352
endfunc
3353+
3354+
func Test_lbuffer_with_bwipe()
3355+
new
3356+
new
3357+
augroup nasty
3358+
au * * bwipe
3359+
augroup END
3360+
lbuffer
3361+
augroup nasty
3362+
au!
3363+
augroup END
3364+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
60,
764766
/**/
765767
59,
766768
/**/

0 commit comments

Comments
 (0)