vim-patch:9.0.1145: invalid memory access with recursive substitute expression (#23132)

Problem:    Invalid memory access with recursive substitute expression.
Solution:   Check the return value of vim_regsub().

3ac1d97a1d

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-04-16 18:43:15 +08:00
committed by GitHub
parent 7f94a032e1
commit 227f06b7df
2 changed files with 20 additions and 0 deletions

View File

@@ -1109,6 +1109,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