diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-10-05 21:33:08 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-10-05 22:40:28 +0800 |
commit | a66b12378b1431f886c9b4235160abb171bcb05a (patch) | |
tree | cac95b5d8ff20b8382bebcb43e939adca9c252bc /src | |
parent | 0ae47000e060ad21896c0bb434e99d9a7d8c02b9 (diff) | |
download | rneovim-a66b12378b1431f886c9b4235160abb171bcb05a.tar.gz rneovim-a66b12378b1431f886c9b4235160abb171bcb05a.tar.bz2 rneovim-a66b12378b1431f886c9b4235160abb171bcb05a.zip |
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.
https://github.com/vim/vim/commit/6bcb877ec19a647443195a54eeac60cb693fd827
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/arglist.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index 4e122f1511..7019a6f461 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -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); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 07042eab32..c320d3ca78 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -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 |