mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 09:18:19 +00:00
vim-patch:9.0.0260: using freed memory when using 'quickfixtextfunc' recursively
Problem: Using freed memory when using 'quickfixtextfunc' recursively.
Solution: Do not allow for recursion.
d6c67629ed
Cherry-pick Test_qflist_statusmsg() from patch 8.2.4617.
This commit is contained in:
@@ -3984,6 +3984,12 @@ static list_T *call_qftf_func(qf_list_T *qfl, int qf_winid, long start_idx, long
|
|||||||
{
|
{
|
||||||
Callback *cb = &qftf_cb;
|
Callback *cb = &qftf_cb;
|
||||||
list_T *qftf_list = NULL;
|
list_T *qftf_list = NULL;
|
||||||
|
static bool recursive = false;
|
||||||
|
|
||||||
|
if (recursive) {
|
||||||
|
return NULL; // this doesn't work properly recursively
|
||||||
|
}
|
||||||
|
recursive = true;
|
||||||
|
|
||||||
// If 'quickfixtextfunc' is set, then use the user-supplied function to get
|
// If 'quickfixtextfunc' is set, then use the user-supplied function to get
|
||||||
// the text to display. Use the local value of 'quickfixtextfunc' if it is
|
// the text to display. Use the local value of 'quickfixtextfunc' if it is
|
||||||
@@ -4017,6 +4023,7 @@ static list_T *call_qftf_func(qf_list_T *qfl, int qf_winid, long start_idx, long
|
|||||||
tv_dict_unref(dict);
|
tv_dict_unref(dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recursive = false;
|
||||||
return qftf_list;
|
return qftf_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5839,4 +5839,52 @@ func Test_getqflist_wiped_out_buffer()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for the status message that is displayed when opening a new quickfix
|
||||||
|
" list
|
||||||
|
func Test_qflist_statusmsg()
|
||||||
|
cexpr "1\n2"
|
||||||
|
cexpr "1\n2\n3\ntest_quickfix.vim:1:msg"
|
||||||
|
call assert_equal('(4 of 4): msg', v:statusmsg)
|
||||||
|
call setqflist([], 'f')
|
||||||
|
%bw!
|
||||||
|
|
||||||
|
" When creating a new quickfix list, if an autocmd changes the quickfix list
|
||||||
|
" in the stack, then an error message should be displayed.
|
||||||
|
augroup QF_Test
|
||||||
|
au!
|
||||||
|
au BufEnter test_quickfix.vim colder
|
||||||
|
augroup END
|
||||||
|
cexpr "1\n2"
|
||||||
|
call assert_fails('cexpr "1\n2\n3\ntest_quickfix.vim:1:msg"', 'E925:')
|
||||||
|
call setqflist([], 'f')
|
||||||
|
augroup QF_Test
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
%bw!
|
||||||
|
|
||||||
|
augroup QF_Test
|
||||||
|
au!
|
||||||
|
au BufEnter test_quickfix.vim caddexpr "4"
|
||||||
|
augroup END
|
||||||
|
call assert_fails('cexpr "1\n2\n3\ntest_quickfix.vim:1:msg"', 'E925:')
|
||||||
|
call setqflist([], 'f')
|
||||||
|
augroup QF_Test
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_quickfixtextfunc_recursive()
|
||||||
|
func s:QFTfunc(o)
|
||||||
|
cgete '0'
|
||||||
|
endfunc
|
||||||
|
copen
|
||||||
|
let &quickfixtextfunc = 's:QFTfunc'
|
||||||
|
cex ""
|
||||||
|
|
||||||
|
let &quickfixtextfunc = ''
|
||||||
|
cclose
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Reference in New Issue
Block a user