summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_substitute.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2023-01-04 17:17:54 +0000
committerBram Moolenaar <Bram@vim.org>2023-01-04 17:17:54 +0000
commit3ac1d97a1d9353490493d30088256360435f7731 (patch)
treeabb98762b33578fd248937ad21d1099e19a3e081 /src/testdir/test_substitute.vim
parentc32949b0779106ed5710ae3bffc5053e49083ab4 (diff)
patch 9.0.1145: invalid memory access with recursive substitute expressionv9.0.1145
Problem: Invalid memory access with recursive substitute expression. Solution: Check the return value of vim_regsub().
Diffstat (limited to 'src/testdir/test_substitute.vim')
-rw-r--r--src/testdir/test_substitute.vim16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim
index 2513223372..4268aab03f 100644
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -1115,6 +1115,22 @@ func Test_sub_expr_goto_other_file()
bwipe!
endfunc
+func Test_recursive_expr_substitute()
+ " this was reading invalid memory
+ let lines =<< trim END
+ func Repl(g, n)
+ s
+ r%:s000
+ endfunc
+ next 0
+ let caught = 0
+ s/\%')/\=Repl(0, 0)
+ qall!
+ END
+ call writefile(lines, 'XexprSubst', 'D')
+ call RunVim([], [], '--clean -S XexprSubst')
+endfunc
+
" Test for the 2-letter and 3-letter :substitute commands
func Test_substitute_short_cmd()
new