diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-02-03 21:23:29 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-02-03 21:23:29 +0100 |
commit | 6bcb877ec19a647443195a54eeac60cb693fd827 (patch) | |
tree | 03771c400bda7fb02e8466d0a3f3a281d61a35a0 | |
parent | 2c363a2e95ee0b366e72063d093d20e025ef4a66 (diff) | |
download | vim-git-6bcb877ec19a647443195a54eeac60cb693fd827.tar.gz |
patch 8.2.2463: using :arglocal in an autocommand may use freed memoryv8.2.2463
Problem: Using :arglocal in an autocommand may use freed memory.
(houyunsong)
Solution: Check if the arglist is locked.
-rw-r--r-- | src/arglist.c | 4 | ||||
-rw-r--r-- | src/testdir/test_autocmd.vim | 9 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 15 insertions, 0 deletions
diff --git a/src/arglist.c b/src/arglist.c index 503cbd90d..79628fda6 100644 --- a/src/arglist.c +++ b/src/arglist.c @@ -557,6 +557,8 @@ 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; @@ -566,6 +568,8 @@ 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); diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index dab699155..71f8d2d60 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -2717,4 +2717,13 @@ func Test_close_autocmd_tab() %bwipe! 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 diff --git a/src/version.c b/src/version.c index a7288f385..53ed13c73 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2463, +/**/ 2462, /**/ 2461, |