Skip to content

Commit d0fab10

Browse files
committed
patch 9.0.0805: filetype autocmd may cause freed memory access
Problem: Filetype autocmd may cause freed memory access. Solution: Set the quickfix-busy flag while filling the buffer.
1 parent cdef1ce commit d0fab10

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/quickfix.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,6 +4595,9 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
45954595
qf_winid = win->w_id;
45964596
}
45974597

4598+
// autocommands may cause trouble
4599+
incr_quickfix_busy();
4600+
45984601
if (old_last == NULL)
45994602
// set curwin/curbuf to buf and save a few things
46004603
aucmd_prepbuf(&aco, buf);
@@ -4616,6 +4619,9 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
46164619
// when the added lines are not visible.
46174620
if ((win = qf_find_win(qi)) != NULL && old_line_count < win->w_botline)
46184621
redraw_buf_later(buf, UPD_NOT_VALID);
4622+
4623+
// always called after incr_quickfix_busy()
4624+
decr_quickfix_busy();
46194625
}
46204626
}
46214627

src/testdir/test_quickfix.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3455,6 +3455,21 @@ func Test_resize_from_copen()
34553455
endtry
34563456
endfunc
34573457

3458+
func Test_filetype_autocmd()
3459+
" this changes the location list while it is in use to fill a buffer
3460+
lexpr ''
3461+
lopen
3462+
augroup FT_loclist
3463+
au FileType * call setloclist(0, [], 'f')
3464+
augroup END
3465+
silent! lolder
3466+
lexpr ''
3467+
3468+
augroup FT_loclist
3469+
au! FileType
3470+
augroup END
3471+
endfunc
3472+
34583473
func Test_vimgrep_with_textlock()
34593474
new
34603475

@@ -6372,4 +6387,5 @@ func Test_info_line_with_space()
63726387
call setqflist([], 'f')
63736388
endfunc
63746389

6390+
63756391
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

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

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
805,
698700
/**/
699701
804,
700702
/**/

0 commit comments

Comments
 (0)