]> granicus.if.org Git - vim/commitdiff
patch 8.1.0073: crash when autocommands call setloclist() v8.1.0073
authorBram Moolenaar <Bram@vim.org>
Mon, 18 Jun 2018 18:52:13 +0000 (20:52 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 18 Jun 2018 18:52:13 +0000 (20:52 +0200)
Problem:    Crash when autocommands call setloclist(). (Dominique Pelle)
Solution:   If the quickfix list changes then don't jump to the error.

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

index 031c6e7a6ba3869404163313a6468bd98843c498..fb1cb4e8688f5df253f6aec790f06c82f342524e 100644 (file)
@@ -6348,9 +6348,11 @@ ex_cexpr(exarg_T *eap)
            if (au_name != NULL)
                apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
                                                curbuf->b_fname, TRUE, curbuf);
-           if (res > 0 && (eap->cmdidx == CMD_cexpr ||
-                                               eap->cmdidx == CMD_lexpr))
-               qf_jump(qi, 0, 0, eap->forceit);  /* display first error */
+           if (res > 0 && (eap->cmdidx == CMD_cexpr
+                                                  || eap->cmdidx == CMD_lexpr)
+                   && qi == ll_get_or_alloc_list(curwin))
+               // Jump to the first error if autocmds didn't free the list.
+               qf_jump(qi, 0, 0, eap->forceit);
        }
        else
            EMSG(_("E777: String or List expected"));
index eade52f42d1eaec67e59fe7f908dcb49e4717b2c..80f327d64ab9faaf3efaab1abc6ebc97947b6db3 100644 (file)
@@ -3362,3 +3362,14 @@ func Test_lbuffer_with_bwipe()
     au!
   augroup END
 endfunc
+
+func Test_setloclist_in_aucmd()
+  " This was using freed memory.
+  augroup nasty
+    au * * call setloclist(0, [], 'f')
+  augroup END
+  lexpr "x"
+  augroup nasty
+    au!
+  augroup END
+endfunc
index 6ce67802d7f482c79862431a6730eada34b50993..36c57e249ebbba084b0f1f57e5dfb89c6089fc7c 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    73,
 /**/
     72,
 /**/