mirror of
https://github.com/neovim/neovim.git
synced 2025-10-14 13:56:05 +00: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:
@@ -490,6 +490,9 @@ void check_arg_idx(win_T *win)
|
|||||||
void ex_args(exarg_T *eap)
|
void ex_args(exarg_T *eap)
|
||||||
{
|
{
|
||||||
if (eap->cmdidx != CMD_args) {
|
if (eap->cmdidx != CMD_args) {
|
||||||
|
if (check_arglist_locked() == FAIL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
alist_unlink(ALIST(curwin));
|
alist_unlink(ALIST(curwin));
|
||||||
if (eap->cmdidx == CMD_argglobal) {
|
if (eap->cmdidx == CMD_argglobal) {
|
||||||
ALIST(curwin) = &global_alist;
|
ALIST(curwin) = &global_alist;
|
||||||
@@ -499,6 +502,9 @@ void ex_args(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*eap->arg != NUL) {
|
if (*eap->arg != NUL) {
|
||||||
|
if (check_arglist_locked() == FAIL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// ":args file ..": define new argument list, handle like ":next"
|
// ":args file ..": define new argument list, handle like ":next"
|
||||||
// Also for ":argslocal file .." and ":argsglobal file ..".
|
// Also for ":argslocal file .." and ":argsglobal file ..".
|
||||||
ex_next(eap);
|
ex_next(eap);
|
||||||
|
@@ -3010,6 +3010,15 @@ func Test_Visual_doautoall_redraw()
|
|||||||
%bwipe!
|
%bwipe!
|
||||||
endfunc
|
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()
|
func Test_autocmd_closes_window()
|
||||||
au BufNew,BufWinLeave * e %e
|
au BufNew,BufWinLeave * e %e
|
||||||
file yyy
|
file yyy
|
||||||
|
Reference in New Issue
Block a user