summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-06-18 20:52:13 +0200
committerBram Moolenaar <Bram@vim.org>2018-06-18 20:52:13 +0200
commit0366c0161e988e32420d2f37111a60129684905b (patch)
tree49a620a3a1769dd1edc76a138e9b2fd941c3dd11
parentdcdeaaf1505b96aa7a31ccd4becc92c32119bdda (diff)
downloadvim-0366c0161e988e32420d2f37111a60129684905b.zip
patch 8.1.0073: crash when autocommands call setloclist()
Problem: Crash when autocommands call setloclist(). (Dominique Pelle) Solution: If the quickfix list changes then don't jump to the error.
-rw-r--r--src/quickfix.c8
-rw-r--r--src/testdir/test_quickfix.vim11
-rw-r--r--src/version.c2
3 files changed, 18 insertions, 3 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index 031c6e7a6..fb1cb4e86 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -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"));
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index eade52f42..80f327d64 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -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
diff --git a/src/version.c b/src/version.c
index 6ce67802d..36c57e249 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 */
/**/
+ 73,
+/**/
72,
/**/
71,