diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-02-06 19:19:42 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-02-06 19:19:42 +0100 |
commit | 2c7080bf1ceef4a7779644fd428b2386a0676794 (patch) | |
tree | cf62c06da02ed3c688e3e8258191f5f61df1b8d8 | |
parent | 8c6951fa2836a1ae3257770e7b927a9380439912 (diff) |
patch 8.2.2474: using freed memory when window is closed by autocommandv8.2.2474
Problem: Using freed memory when window is closed by autocommand.
(houyunsong)
Solution: Check the window pointer is still valid.
-rw-r--r-- | src/quickfix.c | 2 | ||||
-rw-r--r-- | src/testdir/test_autocmd.vim | 14 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/quickfix.c b/src/quickfix.c index 742a1ee713..910c806f18 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -2603,6 +2603,8 @@ qflist_valid(win_T *wp, int_u qf_id) if (wp != NULL) { + if (!win_valid(wp)) + return FALSE; qi = GET_LOC_LIST(wp); // Location list if (qi == NULL) return FALSE; diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index 15d237ee1d..e07731d6e5 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -2783,4 +2783,18 @@ func Test_autocmd_closing_cmdwin() only endfunc +func Test_autocmd_vimgrep() + augroup aucmd_vimgrep + au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb + au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9 + augroup END + " TODO: if this is executed directly valgrind reports errors + call assert_fails('lv?a?', 'E926:') + + augroup aucmd_vimgrep + au! + augroup END +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 254aafdb8e..12a5de8564 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2474, +/**/ 2473, /**/ 2472, |