]> granicus.if.org Git - vim/commitdiff
patch 8.0.1414: accessing freed memory in :lfile. v8.0.1414
authorBram Moolenaar <Bram@vim.org>
Tue, 19 Dec 2017 15:48:55 +0000 (16:48 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 19 Dec 2017 15:48:55 +0000 (16:48 +0100)
Problem:    Accessing freed memory in :lfile.
Solution:   Get the current window after executing autocommands. (Yegappan
            Lakshmanan, closes #2473)

src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index 87c60858014fefda59fac42d25a9cb1e045c36de..5deaed531cdedd676293dc896b582103e483762f 100644 (file)
@@ -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.
index 8d0c198ba0005fb9bf22c812aa9d3c231b764341..a09ec738ec29a0696df248e5a357eb6b5d8a25cc 100644 (file)
@@ -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
index 479116bd6b58ef69f36de5f9f70a6067c6a6a277..cba8fcfc026535074ab2595a3c85b8164a7915d7 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1414,
 /**/
     1413,
 /**/