mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.2463: using :arglocal in an autocommand may use freed memory
Problem: Using :arglocal in an autocommand may use freed memory.
(houyunsong)
Solution: Check if the arglist is locked.
6bcb877ec1
This commit is contained in:
parent
0ae47000e0
commit
a66b12378b
@ -490,6 +490,9 @@ void check_arg_idx(win_T *win)
|
||||
void ex_args(exarg_T *eap)
|
||||
{
|
||||
if (eap->cmdidx != CMD_args) {
|
||||
if (check_arglist_locked() == FAIL) {
|
||||
return;
|
||||
}
|
||||
alist_unlink(ALIST(curwin));
|
||||
if (eap->cmdidx == CMD_argglobal) {
|
||||
ALIST(curwin) = &global_alist;
|
||||
@ -499,6 +502,9 @@ void ex_args(exarg_T *eap)
|
||||
}
|
||||
|
||||
if (*eap->arg != NUL) {
|
||||
if (check_arglist_locked() == FAIL) {
|
||||
return;
|
||||
}
|
||||
// ":args file ..": define new argument list, handle like ":next"
|
||||
// Also for ":argslocal file .." and ":argsglobal file ..".
|
||||
ex_next(eap);
|
||||
|
@ -3010,6 +3010,15 @@ func Test_Visual_doautoall_redraw()
|
||||
%bwipe!
|
||||
endfunc
|
||||
|
||||
" This was using freed memory.
|
||||
func Test_BufNew_arglocal()
|
||||
arglocal
|
||||
au BufNew * arglocal
|
||||
call assert_fails('drop xx', 'E1156:')
|
||||
|
||||
au! BufNew
|
||||
endfunc
|
||||
|
||||
func Test_autocmd_closes_window()
|
||||
au BufNew,BufWinLeave * e %e
|
||||
file yyy
|
||||
|
Loading…
Reference in New Issue
Block a user