diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-20 09:44:12 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-04-21 19:07:50 +0800 |
commit | 69ac382a283c92c54fc40b0017688a60fe89a49c (patch) | |
tree | 1b3a730a33007b5efa7c14c658bedfd2dda793d4 /src | |
parent | fa15f2f9380433b4d22387ce313bd4735b960c4e (diff) | |
download | rneovim-69ac382a283c92c54fc40b0017688a60fe89a49c.tar.gz rneovim-69ac382a283c92c54fc40b0017688a60fe89a49c.tar.bz2 rneovim-69ac382a283c92c54fc40b0017688a60fe89a49c.zip |
vim-patch:8.2.2474: using freed memory when window is closed by autocommand
Problem: Using freed memory when window is closed by autocommand.
(houyunsong)
Solution: Check the window pointer is still valid.
https://github.com/vim/vim/commit/2c7080bf1ceef4a7779644fd428b2386a0676794
Add missing comment from Vim patch 8.0.1420.
Test fails.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/quickfix.c | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 13 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index f8d2d37a91..a12fb70388 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2313,7 +2313,10 @@ static bool qflist_valid(win_T *wp, unsigned int qf_id) qf_info_T *qi = &ql_info; if (wp) { - qi = GET_LOC_LIST(wp); + if (!win_valid(wp)) { + return false; + } + qi = GET_LOC_LIST(wp); // Location list if (!qi) { return false; } diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 7ad3c8c6ad..6cfca21f71 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2741,6 +2741,19 @@ 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 + func Test_bufwipeout_changes_window() " This should not crash, but we don't have any expectations about what " happens, changing window in BufWipeout has unpredictable results. |