Skip to content

Commit 0366c01

Browse files
committed
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.
1 parent dcdeaaf commit 0366c01

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/quickfix.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -6348,9 +6348,11 @@ ex_cexpr(exarg_T *eap)
63486348
if (au_name != NULL)
63496349
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
63506350
curbuf->b_fname, TRUE, curbuf);
6351-
if (res > 0 && (eap->cmdidx == CMD_cexpr ||
6352-
eap->cmdidx == CMD_lexpr))
6353-
qf_jump(qi, 0, 0, eap->forceit); /* display first error */
6351+
if (res > 0 && (eap->cmdidx == CMD_cexpr
6352+
|| eap->cmdidx == CMD_lexpr)
6353+
&& qi == ll_get_or_alloc_list(curwin))
6354+
// Jump to the first error if autocmds didn't free the list.
6355+
qf_jump(qi, 0, 0, eap->forceit);
63546356
}
63556357
else
63566358
EMSG(_("E777: String or List expected"));

src/testdir/test_quickfix.vim

+11
Original file line numberDiff line numberDiff line change
@@ -3362,3 +3362,14 @@ func Test_lbuffer_with_bwipe()
33623362
au!
33633363
augroup END
33643364
endfunc
3365+
3366+
func Test_setloclist_in_aucmd()
3367+
" This was using freed memory.
3368+
augroup nasty
3369+
au * * call setloclist(0, [], 'f')
3370+
augroup END
3371+
lexpr "x"
3372+
augroup nasty
3373+
au!
3374+
augroup END
3375+
endfunc

src/version.c

+2
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+
73,
764766
/**/
765767
72,
766768
/**/

0 commit comments

Comments
 (0)