diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-29 14:21:51 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-29 14:21:51 +0000 |
commit | 37f47958b8a2a44abc60614271d9537e7f14e51a (patch) | |
tree | 93ecab84af2e5191851cef159b559f2267ef233e /src/testdir/test_substitute.vim | |
parent | 4dc0dd869972ddafc7d9ee5ea765645b818a6dc9 (diff) |
patch 8.2.4253: using freed memory when substitute with function callv8.2.4253
Problem: Using freed memory when substitute uses a recursive function call.
Solution: Make a copy of the substitute text.
Diffstat (limited to 'src/testdir/test_substitute.vim')
-rw-r--r-- | src/testdir/test_substitute.vim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim index 0806fd2de6..35b6b8a024 100644 --- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -980,4 +980,21 @@ func Test_substitute_gdefault() bw! endfunc +" This was using "old_sub" after it was freed. +func Test_using_old_sub() + set compatible maxfuncdepth=10 + new + call setline(1, 'some text.') + func Repl() + ~ + s/ + endfunc + silent! s/\%')/\=Repl() + + delfunc Repl + bwipe! + set nocompatible +endfunc + + " vim: shiftwidth=2 sts=2 expandtab |