summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-12-19 16:48:55 +0100
committerBram Moolenaar <Bram@vim.org>2017-12-19 16:48:55 +0100
commit14a4deb064610c30a50f00d524dde9b3292aad59 (patch)
treee174eb5685a6083e31c21b3a9f9ea75e751a6e53
parentaaf6e43b7a99cedb89d73ba749a46f7a0f16bbb6 (diff)
downloadvim-git-14a4deb064610c30a50f00d524dde9b3292aad59.tar.gz
patch 8.0.1414: accessing freed memory in :lfile.v8.0.1414
Problem: Accessing freed memory in :lfile. Solution: Get the current window after executing autocommands. (Yegappan Lakshmanan, closes #2473)
-rw-r--r--src/quickfix.c9
-rw-r--r--src/testdir/test_quickfix.vim7
-rw-r--r--src/version.c2
3 files changed, 14 insertions, 4 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index 87c608580..5deaed531 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -4068,10 +4068,6 @@ ex_cfile(exarg_T *eap)
#endif
int res;
- if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
- || eap->cmdidx == CMD_laddfile)
- wp = curwin;
-
#ifdef FEAT_AUTOCMD
switch (eap->cmdidx)
{
@@ -4104,6 +4100,11 @@ ex_cfile(exarg_T *eap)
if (*eap->arg != NUL)
set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0);
+ if (eap->cmdidx == CMD_lfile
+ || eap->cmdidx == CMD_lgetfile
+ || eap->cmdidx == CMD_laddfile)
+ wp = curwin;
+
/*
* This function is used by the :cfile, :cgetfile and :caddfile
* commands.
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index 8d0c198ba..a09ec738e 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -3031,3 +3031,10 @@ func Test_ll_window_ctx()
enew | only
endfunc
+" The following test used to crash vim
+func Test_lfile_crash()
+ sp Xtest
+ au QuickFixCmdPre * bw
+ call assert_fails('lfile', 'E40')
+ au! QuickFixCmdPre
+endfunc
diff --git a/src/version.c b/src/version.c
index 479116bd6..cba8fcfc0 100644
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1414,
+/**/
1413,
/**/
1412,