aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-11-12 08:06:58 -0500
committerJames McCoy <jamessan@jamessan.com>2016-11-15 23:16:08 -0500
commit7231438f124eff0ce0b9a8998ac7838abc094a8b (patch)
treeccca11f0c8cb5f332835bbe2489022f0e9a10ccd /src
parentaba853a156229c7df6686a6592003b5075e79e2d (diff)
downloadrneovim-7231438f124eff0ce0b9a8998ac7838abc094a8b.tar.gz
rneovim-7231438f124eff0ce0b9a8998ac7838abc094a8b.tar.bz2
rneovim-7231438f124eff0ce0b9a8998ac7838abc094a8b.zip
vim-patch:7.4.1640
Problem: Crash when an autocommand changes a quickfix list. (Dominique) Solution: Check wether an entry is still valid. (Yegappan Lakshmanan, Hirohito Higashi) https://github.com/vim/vim/commit/ffec3c53496d49668669deabc0724ec78e2274fd
Diffstat (limited to 'src')
-rw-r--r--src/nvim/quickfix.c43
-rw-r--r--src/nvim/version.c2
2 files changed, 43 insertions, 2 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index d6697902ef..71fcb5e60f 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1254,6 +1254,32 @@ static char_u *qf_guess_filepath(char_u *filename)
}
+/// When loading a file from the quickfix, the auto commands may modify it.
+/// This may invalidate the current quickfix entry. This function checks
+/// whether a entry is still present in the quickfix.
+/// Similar to location list.
+static bool is_qf_entry_present(qf_info_T *qi, qfline_T *qf_ptr)
+{
+ qf_list_T *qfl;
+ qfline_T *qfp;
+ int i;
+
+ qfl = &qi->qf_lists[qi->qf_curlist];
+
+ // Search for the entry in the current list
+ for (i = 0, qfp = qfl->qf_start; i < qfl->qf_count; i++, qfp = qfp->qf_next) {
+ if (qfp == qf_ptr) {
+ break;
+ }
+ }
+
+ if (i == qfl->qf_count) { // Entry is not found
+ return false;
+ }
+
+ return true;
+}
+
/*
* jump to a quickfix line
* if dir == FORWARD go "errornr" valid entries forward
@@ -1585,14 +1611,29 @@ win_found:
oldwin == curwin ? curwin : NULL);
}
} else {
+ int old_qf_curlist = qi->qf_curlist;
+ bool is_abort = false;
+
ok = buflist_getfile(qf_ptr->qf_fnum, (linenr_T)1,
GETF_SETMARK | GETF_SWITCH, forceit);
if (qi != &ql_info && !win_valid(oldwin)) {
EMSG(_("E924: Current window was closed"));
+ is_abort = true;
+ opened_window = false;
+ } else if (old_qf_curlist != qi->qf_curlist
+ || !is_qf_entry_present(qi, qf_ptr)) {
+ if (qi == &ql_info) {
+ EMSG(_("E925: Current quickfix was changed"));
+ } else {
+ EMSG(_("E926: Current location list was changed"));
+ }
+ is_abort = true;
+ }
+
+ if (is_abort) {
ok = false;
qi = NULL;
qf_ptr = NULL;
- opened_window = false;
}
}
}
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 7721e9dc8c..69438c50d0 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -804,7 +804,7 @@ static int included_patches[] = {
1643,
1642,
1641,
- // 1640,
+ 1640,
// 1639,
// 1638,
// 1637 NA