diff src/testdir/test_substitute.vim @ 29255:5ebc561444fe v8.2.5146

patch 8.2.5146: memory leak when substitute expression nests Commit: https://github.com/vim/vim/commit/44ddf19ec0ff59c969658ec7d9ed42070c59c51b Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 21 22:15:25 2022 +0100 patch 8.2.5146: memory leak when substitute expression nests Problem: Memory leak when substitute expression nests. Solution: Use an array of expression results.
author Bram Moolenaar <Bram@vim.org>
date Tue, 21 Jun 2022 23:30:03 +0200
parents 9e0b45df95b0
children 13b02c1ea0f7
line wrap: on
line diff
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -995,7 +995,7 @@ func Test_using_old_sub()
     ~
     s/
   endfunc
-  silent!  s/\%')/\=Repl()
+  silent! s/\%')/\=Repl()
 
   delfunc Repl
   bwipe!
@@ -1359,4 +1359,14 @@ func Test_substitute_short_cmd()
   bw!
 endfunc
 
+" This should be done last to reveal a memory leak when vim_regsub_both() is
+" called to evaluate an expression but it is not used in a second call.
+func Test_z_substitute_expr_leak()
+  func SubExpr()
+    ~n
+  endfunc
+  silent! s/\%')/\=SubExpr()
+  delfunc SubExpr
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab