Mercurial > vim
changeset 29214:9e0b45df95b0 v8.2.5126
patch 8.2.5126: substitute may overrun destination buffer
Commit: https://github.com/vim/vim/commit/d6211a52ab9f53b82f884561ed43d2fe4d24ff7d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 18 19:48:14 2022 +0100
patch 8.2.5126: substitute may overrun destination buffer
Problem: Substitute may overrun destination buffer.
Solution: Disallow switching buffers in a substitute expression.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Jun 2022 21:00:04 +0200 |
parents | 6400a0abf095 |
children | 9a23a8dec93f |
files | src/ex_docmd.c src/testdir/test_substitute.vim src/version.c |
diffstat | 3 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -7138,9 +7138,10 @@ do_exedit( #endif ) { - // Can't edit another file when "curbuf_lock" is set. Only ":edit" - // can bring us here, others are stopped earlier. - if (*eap->arg != NUL && curbuf_locked()) + // Can't edit another file when "textlock" or "curbuf_lock" is set. + // Only ":edit" or ":script" can bring us here, others are stopped + // earlier. + if (*eap->arg != NUL && text_or_buf_locked()) return; n = readonlymode;
--- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -1063,6 +1063,19 @@ func Test_sub_open_cmdline_win() call delete('Xresult') endfunc +" This was editing a script file from the expression +func Test_sub_edit_scriptfile() + new + norm o0000000000000000000000000000000000000000000000000000 + func EditScript() + silent! scr! Xfile + endfunc + s/\%')/\=EditScript() + + delfunc EditScript + bwipe! +endfunc + " Test for the 2-letter and 3-letter :substitute commands func Test_substitute_short_cmd() new