neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit a66b12378b1431f886c9b4235160abb171bcb05a
parent 0ae47000e060ad21896c0bb434e99d9a7d8c02b9
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Wed,  5 Oct 2022 21:33:08 +0800

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:
Msrc/nvim/arglist.c | 6++++++
Msrc/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 @@ -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 @@ -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