aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-03 03:40:31 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-12-03 03:42:43 +0800
commit1e6d5fdf3f15142dafef6c5bd32ebacf383460f1 (patch)
tree5dbc9b009ef6819e6dd4b5857f1f4518829a8ee5 /src
parent70ac0c9358251bf54f29a30a369880d94680ace7 (diff)
downloadrneovim-1e6d5fdf3f15142dafef6c5bd32ebacf383460f1.tar.gz
rneovim-1e6d5fdf3f15142dafef6c5bd32ebacf383460f1.tar.bz2
rneovim-1e6d5fdf3f15142dafef6c5bd32ebacf383460f1.zip
vim-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. https://github.com/vim/vim/commit/d0fab10ed2a86698937e3c3fed2f10bd9bb5e731 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/quickfix.c6
-rw-r--r--src/nvim/testdir/test_quickfix.vim16
2 files changed, 22 insertions, 0 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index deac0bb8a1..d4dff746c7 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -3900,6 +3900,9 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
qf_winid = (int)win->handle;
}
+ // autocommands may cause trouble
+ incr_quickfix_busy();
+
aco_save_T aco;
if (old_last == NULL) {
@@ -3924,6 +3927,9 @@ static void qf_update_buffer(qf_info_T *qi, qfline_T *old_last)
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();
}
}
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 02cee8a8dd..a6c0b2491a 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -3298,6 +3298,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
@@ -6165,4 +6180,5 @@ func Test_loclist_replace_autocmd()
call setloclist(0, [], 'f')
endfunc
+
" vim: shiftwidth=2 sts=2 expandtab