Skip to content

Commit 2c7080b

Browse files
committed
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.
1 parent 8c6951f commit 2c7080b

3 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/quickfix.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,8 @@ qflist_valid(win_T *wp, int_u qf_id)
26032603

26042604
if (wp != NULL)
26052605
{
2606+
if (!win_valid(wp))
2607+
return FALSE;
26062608
qi = GET_LOC_LIST(wp); // Location list
26072609
if (qi == NULL)
26082610
return FALSE;

src/testdir/test_autocmd.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,4 +2783,18 @@ func Test_autocmd_closing_cmdwin()
27832783
only
27842784
endfunc
27852785

2786+
func Test_autocmd_vimgrep()
2787+
augroup aucmd_vimgrep
2788+
au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb
2789+
au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9
2790+
augroup END
2791+
" TODO: if this is executed directly valgrind reports errors
2792+
call assert_fails('lv?a?', 'E926:')
2793+
2794+
augroup aucmd_vimgrep
2795+
au!
2796+
augroup END
2797+
endfunc
2798+
2799+
27862800
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2474,
753755
/**/
754756
2473,
755757
/**/

0 commit comments

Comments
 (0)