Skip to content

Commit 92bb83e

Browse files
committed
patch 8.2.2465: using freed memory in :psearch
Problem: Using freed memory in :psearch. (houyunsong) Solution: Check the current window is still valid. Fix flaky test.
1 parent 8ab3757 commit 92bb83e

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/search.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,6 +3864,8 @@ find_pattern_in_path(
38643864
#if defined(FEAT_QUICKFIX)
38653865
if (g_do_tagpreview != 0)
38663866
{
3867+
if (!win_valid(curwin_save))
3868+
break;
38673869
if (!GETFILE_SUCCESS(getfile(
38683870
curwin_save->w_buffer->b_fnum, NULL,
38693871
NULL, TRUE, lnum, FALSE)))

src/testdir/test_autocmd.vim

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if has('timers')
6060
let g:triggered = 0
6161
au CursorHoldI * let g:triggered += 1
6262
set updatetime=20
63-
call timer_start(100, 'ExitInsertMode')
63+
call timer_start(200, 'ExitInsertMode')
6464
call feedkeys('a', 'x!')
6565
call assert_equal(1, g:triggered)
6666
unlet g:triggered
@@ -2413,9 +2413,18 @@ func Test_autocmd_was_using_freed_memory()
24132413

24142414
pedit xx
24152415
n x
2416-
au WinEnter * quit
2416+
augroup winenter
2417+
au WinEnter * if winnr('$') > 2 | quit | endif
2418+
augroup END
24172419
split
2418-
au! WinEnter
2420+
2421+
augroup winenter
2422+
au! WinEnter
2423+
augroup END
2424+
2425+
bwipe xx
2426+
bwipe x
2427+
pclose
24192428
endfunc
24202429

24212430
func Test_BufWrite_lockmarks()
@@ -2737,4 +2746,17 @@ func Test_autocmd_closes_window()
27372746
au! BufWinLeave
27382747
endfunc
27392748

2749+
func Test_autocmd_quit_psearch()
2750+
sn aa bb
2751+
augroup aucmd_win_test
2752+
au!
2753+
au BufEnter,BufLeave,BufNew,WinEnter,WinLeave,WinNew * if winnr('$') > 1 | q | endif
2754+
augroup END
2755+
ps /
2756+
2757+
augroup aucmd_win_test
2758+
au!
2759+
augroup END
2760+
endfunc
2761+
27402762
" 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+
2465,
753755
/**/
754756
2464,
755757
/**/

0 commit comments

Comments
 (0)