Skip to content

Commit

Permalink
patch 9.0.0805: filetype autocmd may cause freed memory access
Browse files Browse the repository at this point in the history
Problem:    Filetype autocmd may cause freed memory access.
Solution:   Set the quickfix-busy flag while filling the buffer.
  • Loading branch information
brammool committed Oct 20, 2022
1 parent cdef1ce commit d0fab10
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/quickfix.c
Expand Up @@ -4595,6 +4595,9 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
qf_winid = win->w_id;
}

// autocommands may cause trouble
incr_quickfix_busy();

if (old_last == NULL)
// set curwin/curbuf to buf and save a few things
aucmd_prepbuf(&aco, buf);
Expand All @@ -4616,6 +4619,9 @@ qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
// when the added lines are not visible.
if ((win = qf_find_win(qi)) != NULL && old_line_count < win->w_botline)
redraw_buf_later(buf, UPD_NOT_VALID);

// always called after incr_quickfix_busy()
decr_quickfix_busy();
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/testdir/test_quickfix.vim
Expand Up @@ -3455,6 +3455,21 @@ func Test_resize_from_copen()
endtry
endfunc

func Test_filetype_autocmd()
" this changes the location list while it is in use to fill a buffer
lexpr ''
lopen
augroup FT_loclist
au FileType * call setloclist(0, [], 'f')
augroup END
silent! lolder
lexpr ''

augroup FT_loclist
au! FileType
augroup END
endfunc

func Test_vimgrep_with_textlock()
new

Expand Down Expand Up @@ -6372,4 +6387,5 @@ func Test_info_line_with_space()
call setqflist([], 'f')
endfunc


" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
805,
/**/
804,
/**/
Expand Down

0 comments on commit d0fab10

Please sign in to comment.