aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorerw7 <erw7.github@gmail.com>2020-09-13 01:39:07 +0900
committererw7 <erw7.github@gmail.com>2020-09-14 00:31:19 +0900
commit80eafef3bb54b3d695b4e23d02d2cb4572c6c224 (patch)
tree6e26ef9b19c401ed129db38c8edb5d28b4853373
parent46f973edf00641390c8e3f9fcc3ec415bc07a7e0 (diff)
downloadrneovim-80eafef3bb54b3d695b4e23d02d2cb4572c6c224.tar.gz
rneovim-80eafef3bb54b3d695b4e23d02d2cb4572c6c224.tar.bz2
rneovim-80eafef3bb54b3d695b4e23d02d2cb4572c6c224.zip
vim-patch:8.1.0489: crash when autocmd clears vimpgrep location list
Problem: Crash when autocmd clears vimpgrep location list. Solution: Return from qf_jump_edit_buffer() early. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/b6f1480a6a8b1a6fa4d5da97aeb5f4755b71eb91
-rw-r--r--src/nvim/quickfix.c44
-rw-r--r--src/nvim/testdir/test_quickfix.vim42
2 files changed, 65 insertions, 21 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index f6798ff692..a416bfde14 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -2702,43 +2702,45 @@ static int qf_jump_edit_buffer(qf_info_T *qi, qfline_T *qf_ptr, int forceit,
qf_list_T *qfl = qf_get_curlist(qi);
qfltype_T qfl_type = qfl->qfl_type;
int retval = OK;
+ int old_qf_curlist = qi->qf_curlist;
+ unsigned save_qfid = qfl->qf_id;
if (qf_ptr->qf_type == 1) {
// Open help file (do_ecmd() will set b_help flag, readfile() will
// set b_p_ro flag).
if (!can_abandon(curbuf, forceit)) {
no_write_message();
- retval = FAIL;
+ return FAIL;
} else {
retval = do_ecmd(qf_ptr->qf_fnum, NULL, NULL, NULL, (linenr_T)1,
ECMD_HIDE + ECMD_SET_HELP,
oldwin == curwin ? curwin : NULL);
}
} else {
- unsigned save_qfid = qfl->qf_id;
-
retval = buflist_getfile(qf_ptr->qf_fnum, (linenr_T)1,
GETF_SETMARK | GETF_SWITCH, forceit);
+ }
+ // If a location list, check whether the associated window is still
+ // present.
+ if (qfl_type == QFLT_LOCATION && !win_valid_any_tab(oldwin)) {
+ EMSG(_("E924: Current window was closed"));
+ *opened_window = false;
+ return NOTDONE;
+ }
- if (qfl_type == QFLT_LOCATION) {
- // Location list. Check whether the associated window is still
- // present and the list is still valid.
- if (!win_valid_any_tab(oldwin)) {
- EMSG(_("E924: Current window was closed"));
- *opened_window = false;
- return NOTDONE;
- } else if (!qflist_valid(oldwin, save_qfid)) {
- EMSG(_(e_loc_list_changed));
- return NOTDONE;
- }
- } else if (!is_qf_entry_present(qfl, qf_ptr)) {
- if (qfl_type == QFLT_QUICKFIX) {
- EMSG(_("E925: Current quickfix was changed"));
- } else {
- EMSG(_(e_loc_list_changed));
- }
- return NOTDONE;
+ if (qfl_type == QFLT_QUICKFIX && !qflist_valid(NULL, save_qfid)) {
+ EMSG(_("E925: Current quickfix was changed"));
+ return NOTDONE;
+ }
+
+ if (old_qf_curlist != qi->qf_curlist
+ || !is_qf_entry_present(qfl, qf_ptr)) {
+ if (qfl_type == QFLT_QUICKFIX) {
+ EMSG(_("E925: Current quickfix was changed"));
+ } else {
+ EMSG(_(e_loc_list_changed));
}
+ return NOTDONE;
}
return retval;
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 926103b69f..52226327b1 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -3342,6 +3342,17 @@ func Test_lvimgrep_crash()
augroup QF_Test
au!
augroup END
+
+ new | only
+ augroup QF_Test
+ au!
+ au BufEnter * call setloclist(0, [], 'r')
+ augroup END
+ call assert_fails('lvimgrep Test_lvimgrep_crash *', 'E926:')
+ augroup QF_Test
+ au!
+ augroup END
+
enew | only
endfunc
@@ -3432,6 +3443,37 @@ func Test_lhelpgrep_autocmd()
call assert_equal('help', &filetype)
call assert_equal(1, getloclist(0, {'nr' : '$'}).nr)
au! QuickFixCmdPost
+
+ new | only
+ augroup QF_Test
+ au!
+ au BufEnter * call setqflist([], 'f')
+ augroup END
+ call assert_fails('helpgrep quickfix', 'E925:')
+ augroup QF_Test
+ au! BufEnter
+ augroup END
+
+ new | only
+ augroup QF_Test
+ au!
+ au BufEnter * call setqflist([], 'r')
+ augroup END
+ call assert_fails('helpgrep quickfix', 'E925:')
+ augroup QF_Test
+ au! BufEnter
+ augroup END
+
+ new | only
+ augroup QF_Test
+ au!
+ au BufEnter * call setloclist(0, [], 'r')
+ augroup END
+ call assert_fails('lhelpgrep quickfix', 'E926:')
+ augroup QF_Test
+ au! BufEnter
+ augroup END
+
new | only
endfunc