# HG changeset patch # User Christian Brabandt # Date 1513698306 -3600 # Node ID 7c071a3f7f8ec51c0501a61bee188e7d43c50f9b # Parent d25c0dfb3ec6692922da004cd7cc278780ba4ef6 patch 8.0.1413: accessing freed memory in :cbuffer commit https://github.com/vim/vim/commit/aaf6e43b7a99cedb89d73ba749a46f7a0f16bbb6 Author: Bram Moolenaar Date: Tue Dec 19 16:41:14 2017 +0100 patch 8.0.1413: accessing freed memory in :cbuffer Problem: Accessing freed memory in :cbuffer. Solution: Get quickfix list after executing autocmds. (closes https://github.com/vim/vim/issues/2470) diff --git a/src/quickfix.c b/src/quickfix.c --- 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 --- 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 --- 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,