Mercurial > vim
diff src/ex_cmds.c @ 29048:c98fc7a4dde4 v8.2.5046
patch 8.2.5046: vim_regsub() can overwrite the destination
Commit: https://github.com/vim/vim/commit/4aaf3e7f4db599932d01d87e5bbcdc342cccee27
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 30 20:58:55 2022 +0100
patch 8.2.5046: vim_regsub() can overwrite the destination
Problem: vim_regsub() can overwrite the destination.
Solution: Pass the destination length, give an error when it doesn't fit.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 30 May 2022 22:00:03 +0200 |
parents | 45c182c4f7e9 |
children | b90bca860b5a |
line wrap: on
line diff
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4419,7 +4419,9 @@ ex_substitute(exarg_T *eap) // get length of substitution part sublen = vim_regsub_multi(®match, sub_firstlnum - regmatch.startpos[0].lnum, - sub, sub_firstline, FALSE, magic_isset(), TRUE); + sub, sub_firstline, 0, + REGSUB_BACKSLASH + | (magic_isset() ? REGSUB_MAGIC : 0)); #ifdef FEAT_EVAL --textlock; @@ -4528,7 +4530,9 @@ ex_substitute(exarg_T *eap) #endif (void)vim_regsub_multi(®match, sub_firstlnum - regmatch.startpos[0].lnum, - sub, new_end, TRUE, magic_isset(), TRUE); + sub, new_end, sublen, + REGSUB_COPY | REGSUB_BACKSLASH + | (magic_isset() ? REGSUB_MAGIC : 0)); #ifdef FEAT_EVAL --textlock; #endif