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:
zeertzjq 2022-10-05 21:33:08 +08:00
parent 0ae47000e0
commit a66b12378b
2 changed files with 15 additions and 0 deletions

View File

@ -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);

View File

@ -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