summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-12-19 16:41:14 +0100
committerBram Moolenaar <Bram@vim.org>2017-12-19 16:41:14 +0100
commitaaf6e43b7a99cedb89d73ba749a46f7a0f16bbb6 (patch)
tree6876de8e8e9e854f859a8110b27c908e46d900fe
parent12237448499aaeb8c4f2be7a1deda60c0f160627 (diff)
patch 8.0.1413: accessing freed memory in :cbufferv8.0.1413
Problem: Accessing freed memory in :cbuffer. Solution: Get quickfix list after executing autocmds. (closes #2470)
-rw-r--r--src/quickfix.c17
-rw-r--r--src/testdir/test_autocmd.vim7
-rw-r--r--src/version.c2
3 files changed, 18 insertions, 8 deletions
diff --git a/src/quickfix.c b/src/quickfix.c
index 6e80ddfca3..87c6085801 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -5520,14 +5520,6 @@ ex_cbuffer(exarg_T *eap)
#endif
int res;
- if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
- || eap->cmdidx == CMD_laddbuffer)
- {
- qi = ll_get_or_alloc_list(curwin);
- if (qi == NULL)
- return;
- }
-
#ifdef FEAT_AUTOCMD
switch (eap->cmdidx)
{
@@ -5549,6 +5541,15 @@ ex_cbuffer(exarg_T *eap)
}
#endif
+ /* Must come after autocommands. */
+ if (eap->cmdidx == CMD_lbuffer || eap->cmdidx == CMD_lgetbuffer
+ || eap->cmdidx == CMD_laddbuffer)
+ {
+ qi = ll_get_or_alloc_list(curwin);
+ if (qi == NULL)
+ return;
+ }
+
if (*eap->arg == NUL)
buf = curbuf;
else if (*skipwhite(skipdigits(eap->arg)) == NUL)
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index d8fddffebb..0636c47215 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -1178,3 +1178,10 @@ func Test_nocatch_wipe_dummy_buffer()
call assert_fails('lvĀ½ /x', 'E480')
au!
endfunc
+
+func Test_wipe_cbuffer()
+ sv x
+ au * * bw
+ lb
+ au!
+endfunc
diff --git a/src/version.c b/src/version.c
index 22df4f924d..479116bd6b 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 */
/**/
+ 1413,
+/**/
1412,
/**/
1411,