Skip to content

Commit

Permalink
patch 8.0.1750: crash when clearing loccation list in autocommand
Browse files Browse the repository at this point in the history
Problem:    Crash when clearing loccation list in autocommand.
Solution:   Check if "qi" equals "ql_info". (Yegappan Lakshmanan)
  • Loading branch information
brammool committed Apr 23, 2018
1 parent 6537c42 commit 3b9474b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/quickfix.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5897,7 +5897,6 @@ ex_helpgrep(exarg_T *eap)
char_u *lang; char_u *lang;
#endif #endif
qf_info_T *qi = &ql_info; qf_info_T *qi = &ql_info;
qf_info_T *save_qi;
int new_qi = FALSE; int new_qi = FALSE;
win_T *wp; win_T *wp;
char_u *au_name = NULL; char_u *au_name = NULL;
Expand Down Expand Up @@ -5951,9 +5950,6 @@ ex_helpgrep(exarg_T *eap)
} }
} }


/* Autocommands may change the list. Save it for later comparison */
save_qi = qi;

regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
regmatch.rm_ic = FALSE; regmatch.rm_ic = FALSE;
if (regmatch.regprog != NULL) if (regmatch.regprog != NULL)
Expand Down Expand Up @@ -6086,7 +6082,7 @@ ex_helpgrep(exarg_T *eap)
{ {
apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name,
curbuf->b_fname, TRUE, curbuf); curbuf->b_fname, TRUE, curbuf);
if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL) if (!new_qi && qi != &ql_info && qf_find_buf(qi) == NULL)
/* autocommands made "qi" invalid */ /* autocommands made "qi" invalid */
return; return;
} }
Expand Down
14 changes: 14 additions & 0 deletions src/testdir/test_quickfix.vim
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3175,3 +3175,17 @@ func Test_vimgrep_autocmd()
call delete('Xtest2.txt') call delete('Xtest2.txt')
call setqflist([], 'f') call setqflist([], 'f')
endfunc endfunc

" The following test used to crash Vim
func Test_lhelpgrep_autocmd()
lhelpgrep quickfix
autocmd QuickFixCmdPost * call setloclist(0, [], 'f')
lhelpgrep buffer
call assert_equal('help', &filetype)
call assert_equal(0, getloclist(0, {'nr' : '$'}).nr)
lhelpgrep tabpage
call assert_equal('help', &filetype)
call assert_equal(1, getloclist(0, {'nr' : '$'}).nr)
au! QuickFixCmdPost
new | only
endfunc
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ static char *(features[]) =


static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1750,
/**/ /**/
1749, 1749,
/**/ /**/
Expand Down

0 comments on commit 3b9474b

Please sign in to comment.