diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-05-31 19:55:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-31 19:55:04 +0800 |
commit | 0c95028688dfee776750c4732811508294557ba2 (patch) | |
tree | 35d448b3140a4186fe7979531a04a453ea8a83b9 /src/nvim/ex_cmds.c | |
parent | 1a20aed3fb35e00f96aa18abb69d35912c9e119d (diff) | |
download | rneovim-0c95028688dfee776750c4732811508294557ba2.tar.gz rneovim-0c95028688dfee776750c4732811508294557ba2.tar.bz2 rneovim-0c95028688dfee776750c4732811508294557ba2.zip |
vim-patch:8.2.5046: vim_regsub() can overwrite the destination (#18812)
Problem: vim_regsub() can overwrite the destination.
Solution: Pass the destination length, give an error when it doesn't fit.
https://github.com/vim/vim/commit/4aaf3e7f4db599932d01d87e5bbcdc342cccee27
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index f6bdfc6175..ab0d58d749 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4078,7 +4078,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle // get length of substitution part sublen = vim_regsub_multi(®match, sub_firstlnum - regmatch.startpos[0].lnum, - (char_u *)sub, (char_u *)sub_firstline, false, p_magic, true); + (char_u *)sub, (char_u *)sub_firstline, 0, + REGSUB_BACKSLASH | (p_magic ? REGSUB_MAGIC : 0)); // If getting the substitute string caused an error, don't do // the replacement. // Don't keep flags set by a recursive call @@ -4118,7 +4119,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout, bool do_buf_event, handle (void)vim_regsub_multi(®match, sub_firstlnum - regmatch.startpos[0].lnum, - (char_u *)sub, (char_u *)new_end, true, p_magic, true); + (char_u *)sub, (char_u *)new_end, sublen, + REGSUB_COPY | REGSUB_BACKSLASH | (p_magic ? REGSUB_MAGIC : 0)); sub_nsubs++; did_sub = true; |