0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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.
This commit is contained in:
Bram Moolenaar
2021-02-03 21:23:29 +01:00
parent 2c363a2e95
commit 6bcb877ec1
3 changed files with 15 additions and 0 deletions

View File

@@ -557,6 +557,8 @@ 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;
@@ -566,6 +568,8 @@ 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);

View File

@@ -2717,4 +2717,13 @@ func Test_close_autocmd_tab()
%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
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2463,
/**/ /**/
2462, 2462,
/**/ /**/