To: vim_dev@googlegroups.com Subject: Patch 8.0.1403 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1403 Problem: Using freed buffer in grep command. (gy741, Dominique Pelle) Solution: Lock the dummy buffer to avoid autocommands wiping it out. Files: src/quickfix.c, src/testdir/test_autocmd.vim *** ../vim-8.0.1402/src/quickfix.c 2017-12-12 22:45:07.141808185 +0100 --- src/quickfix.c 2017-12-18 14:46:01.431148097 +0100 *************** *** 4572,4577 **** --- 4572,4578 ---- bufref_T newbuf_to_wipe; int failed = TRUE; aco_save_T aco; + int readfile_result; /* Allocate a buffer without putting it in the buffer list. */ newbuf = buflist_new(NULL, NULL, (linenr_T)1, BLN_DUMMY); *************** *** 4585,4590 **** --- 4586,4594 ---- /* need to open the memfile before putting the buffer in a window */ if (ml_open(newbuf) == OK) { + /* Make sure this buffer isn't wiped out by auto commands. */ + ++newbuf->b_locked; + /* set curwin/curbuf to buf and save a few things */ aucmd_prepbuf(&aco, newbuf); *************** *** 4599,4607 **** curbuf->b_flags &= ~BF_DUMMY; newbuf_to_wipe.br_buf = NULL; ! if (readfile(fname, NULL, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, ! NULL, READ_NEW | READ_DUMMY) == OK && !got_int && !(curbuf->b_flags & BF_NEW)) { --- 4603,4613 ---- curbuf->b_flags &= ~BF_DUMMY; newbuf_to_wipe.br_buf = NULL; ! readfile_result = readfile(fname, NULL, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, ! NULL, READ_NEW | READ_DUMMY); ! --newbuf->b_locked; ! if (readfile_result == OK && !got_int && !(curbuf->b_flags & BF_NEW)) { *** ../vim-8.0.1402/src/testdir/test_autocmd.vim 2017-12-18 12:37:50.667062757 +0100 --- src/testdir/test_autocmd.vim 2017-12-18 14:44:41.375643684 +0100 *************** *** 1171,1173 **** --- 1171,1180 ---- bwipe au! endfunc + + func Test_nocatch_wipe_dummy_buffer() + " Nasty autocommand: wipe buffer on any event. + au * x bwipe + call assert_fails('lvĀ½ /x', 'E480') + au! + endfunc *** ../vim-8.0.1402/src/version.c 2017-12-18 12:37:50.667062757 +0100 --- src/version.c 2017-12-18 15:32:29.611037184 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1403, /**/ -- hundred-and-one symptoms of being an internet addict: 122. You ask if the Netaholics Anonymous t-shirt you ordered can be sent to you via e-mail. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///