Skip to content

Commit aaf6e43

Browse files
committed
patch 8.0.1413: accessing freed memory in :cbuffer
Problem: Accessing freed memory in :cbuffer. Solution: Get quickfix list after executing autocmds. (closes #2470)
1 parent 1223744 commit aaf6e43

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/quickfix.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5520,14 +5520,6 @@ ex_cbuffer(exarg_T *eap)
55205520
#endif
55215521
int res;
55225522

5523-
if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
5524-
|| eap->cmdidx == CMD_laddbuffer)
5525-
{
5526-
qi = ll_get_or_alloc_list(curwin);
5527-
if (qi == NULL)
5528-
return;
5529-
}
5530-
55315523
#ifdef FEAT_AUTOCMD
55325524
switch (eap->cmdidx)
55335525
{
@@ -5549,6 +5541,15 @@ ex_cbuffer(exarg_T *eap)
55495541
}
55505542
#endif
55515543

5544+
/* Must come after autocommands. */
5545+
if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
5546+
|| eap->cmdidx == CMD_laddbuffer)
5547+
{
5548+
qi = ll_get_or_alloc_list(curwin);
5549+
if (qi == NULL)
5550+
return;
5551+
}
5552+
55525553
if (*eap->arg == NUL)
55535554
buf = curbuf;
55545555
else if (*skipwhite(skipdigits(eap->arg)) == NUL)

src/testdir/test_autocmd.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,3 +1178,10 @@ func Test_nocatch_wipe_dummy_buffer()
11781178
call assert_fails('lv½ /x', 'E480')
11791179
au!
11801180
endfunc
1181+
1182+
func Test_wipe_cbuffer()
1183+
sv x
1184+
au * * bw
1185+
lb
1186+
au!
1187+
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+
1413,
774776
/**/
775777
1412,
776778
/**/

0 commit comments

Comments
 (0)