Skip to content

Commit 14a4deb

Browse files
committed
patch 8.0.1414: accessing freed memory in :lfile.
Problem: Accessing freed memory in :lfile. Solution: Get the current window after executing autocommands. (Yegappan Lakshmanan, closes #2473)
1 parent aaf6e43 commit 14a4deb

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/quickfix.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4068,10 +4068,6 @@ ex_cfile(exarg_T *eap)
40684068
#endif
40694069
int res;
40704070

4071-
if (eap->cmdidx == CMD_lfile || eap->cmdidx == CMD_lgetfile
4072-
|| eap->cmdidx == CMD_laddfile)
4073-
wp = curwin;
4074-
40754071
#ifdef FEAT_AUTOCMD
40764072
switch (eap->cmdidx)
40774073
{
@@ -4104,6 +4100,11 @@ ex_cfile(exarg_T *eap)
41044100
if (*eap->arg != NUL)
41054101
set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0);
41064102

4103+
if (eap->cmdidx == CMD_lfile
4104+
|| eap->cmdidx == CMD_lgetfile
4105+
|| eap->cmdidx == CMD_laddfile)
4106+
wp = curwin;
4107+
41074108
/*
41084109
* This function is used by the :cfile, :cgetfile and :caddfile
41094110
* commands.

src/testdir/test_quickfix.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,3 +3031,10 @@ func Test_ll_window_ctx()
30313031
enew | only
30323032
endfunc
30333033

3034+
" The following test used to crash vim
3035+
func Test_lfile_crash()
3036+
sp Xtest
3037+
au QuickFixCmdPre * bw
3038+
call assert_fails('lfile', 'E40')
3039+
au! QuickFixCmdPre
3040+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1414,
774776
/**/
775777
1413,
776778
/**/

0 commit comments

Comments
 (0)