summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-05-28 07:56:36 +0200
committerBram Moolenaar <Bram@vim.org>2017-05-28 07:56:36 +0200
commit6dd4a53502fb4ec1b66104eab1805e7254ad9e41 (patch)
tree5c6f01c84b3afb5381ba5422121f3de79acf1691
parentb4d6c3ea4a59c6d8d4e0e52120596866f0edd510 (diff)
downloadvim-6dd4a53502fb4ec1b66104eab1805e7254ad9e41.zip
patch 8.0.0605: the quickfix cached buffer may become invalid
Problem: The buffer that quickfix caches for performance may become invalid. (Daniel Hahler) Solution: Reset qf_last_bufref in qf_init_ext(). (Daniel Hahler, closes #1728, closes #1676)
-rw-r--r--src/quickfix.c18
-rw-r--r--src/version.c2
2 files changed, 13 insertions, 7 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index 9626cfa43..ce21661a6 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -158,6 +158,13 @@ static qf_info_T *ll_get_or_alloc_list(win_T *);
#define GET_LOC_LIST(wp) (IS_LL_WINDOW(wp) ? wp->w_llist_ref : wp->w_llist)
/*
+ * Looking up a buffer can be slow if there are many. Remember the last one
+ * to make this a lot faster if there are multiple matches in the same file.
+ */
+static char_u *qf_last_bufname = NULL;
+static bufref_T qf_last_bufref = {NULL, 0};
+
+/*
* Read the errorfile "efile" into memory, line by line, building the error
* list. Set the error list's title to qf_title.
* Return -1 for error, number of errors for success.
@@ -1151,6 +1158,10 @@ qf_init_ext(
int retval = -1; /* default: return error flag */
int status;
+ /* Do not used the cached buffer, it may have been wiped out. */
+ vim_free(qf_last_bufname);
+ qf_last_bufname = NULL;
+
vim_memset(&state, 0, sizeof(state));
vim_memset(&fields, 0, sizeof(fields));
#ifdef FEAT_MBYTE
@@ -1660,13 +1671,6 @@ copy_loclist(win_T *from, win_T *to)
}
/*
- * Looking up a buffer can be slow if there are many. Remember the last one
- * to make this a lot faster if there are multiple matches in the same file.
- */
-static char_u *qf_last_bufname = NULL;
-static bufref_T qf_last_bufref = {NULL, 0};
-
-/*
* Get buffer number for file "directory/fname".
* Also sets the b_has_qf_entry flag.
*/
diff --git a/src/version.c b/src/version.c
index bc80ace74..2c5aa06fd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 605,
+/**/
604,
/**/
603,