]> granicus.if.org Git - vim/commitdiff
patch 8.1.0060: crash when autocommands delete the current buffer v8.1.0060
authorBram Moolenaar <Bram@vim.org>
Sat, 16 Jun 2018 20:16:47 +0000 (22:16 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 16 Jun 2018 20:16:47 +0000 (22:16 +0200)
Problem:    Crash when autocommands delete the current buffer. (Dominique
            Pelle)
Solution:   Check that autocommands don't change the buffer.

src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 1b281ceab2b3ef075933e69d6af326ba55b402a8..031c6e7a6ba3869404163313a6468bd98843c498 100644 (file)
@@ -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 */
index c3850ce1f41eb213ba001493b5d33a310e0a7365..eade52f42d1eaec67e59fe7f908dcb49e4717b2c 100644 (file)
@@ -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
index 68b4c26b861396a16bf11795648b8a329e20ec60..6406e6cd87223c4d7bf8ab66c9bc08018628fce3 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    60,
 /**/
     59,
 /**/