aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-11-23 16:34:11 +0800
committerGitHub <noreply@github.com>2023-11-23 16:34:11 +0800
commit6224690c58372fcc415710fddf69045fda53318f (patch)
treeaa87c5a2c7f915ac97844444b310655af5965995 /test
parent879617c9bbbacb0d0f778ff6dd53cc7c95794abe (diff)
parent8d8136bfcf9ea6d0b23638b48e99e09bdc8a9d44 (diff)
downloadrneovim-6224690c58372fcc415710fddf69045fda53318f.tar.gz
rneovim-6224690c58372fcc415710fddf69045fda53318f.tar.bz2
rneovim-6224690c58372fcc415710fddf69045fda53318f.zip
Merge pull request #26162 from zeertzjq/vim-9.0.2121
vim-patch:8.2.2784,9.0.2121
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_substitute.vim48
1 files changed, 46 insertions, 2 deletions
diff --git a/test/old/testdir/test_substitute.vim b/test/old/testdir/test_substitute.vim
index 75062f13aa..a9e317da02 100644
--- a/test/old/testdir/test_substitute.vim
+++ b/test/old/testdir/test_substitute.vim
@@ -4,6 +4,32 @@ source shared.vim
source check.vim
source screendump.vim
+" NOTE: This needs to be the first test to be
+" run in the file, since it depends on
+" that the previous substitution atom
+" was not yet set.
+"
+" recursive call of :s and sub-replace special
+" (did cause heap-use-after free in < v9.0.2121)
+func Test_aaaa_substitute_expr_recursive_special()
+ func R()
+ " FIXME: leaving out the 'n' flag leaks memory, why?
+ %s/./\='.'/gn
+ endfunc
+ new Xfoobar_UAF
+ put ='abcdef'
+ let bufnr = bufnr('%')
+ try
+ silent! :s/./~\=R()/0
+ "call assert_fails(':s/./~\=R()/0', 'E939:')
+ let @/='.'
+ ~g
+ catch /^Vim\%((\a\+)\)\=:E565:/
+ endtry
+ delfunc R
+ exe bufnr .. "bw!"
+endfunc
+
func Test_multiline_subst()
enew!
call append(0, ["1 aa",
@@ -147,7 +173,6 @@ func Test_substitute_repeat()
call feedkeys("Qsc\<CR>y", 'tx')
bwipe!
endfunc
-
" Test %s/\n// which is implemented as a special case to use a
" more efficient join rather than doing a regular substitution.
func Test_substitute_join()
@@ -1448,11 +1473,30 @@ func Test_substitute_expr_switch_win()
endfunc
new Xfoobar
let bufnr = bufnr('%')
- put ="abcdef"
+ put ='abcdef'
silent! s/\%')/\=R()
call assert_fails(':%s/./\=R()/g', 'E565:')
delfunc R
exe bufnr .. "bw!"
endfunc
+" recursive call of :s using test-replace special
+func Test_substitute_expr_recursive()
+ func Q()
+ %s/./\='foobar'/gn
+ return "foobar"
+ endfunc
+ func R()
+ %s/./\=Q()/g
+ endfunc
+ new Xfoobar_UAF
+ let bufnr = bufnr('%')
+ put ='abcdef'
+ silent! s/./\=R()/g
+ call assert_fails(':%s/./\=R()/g', 'E565:')
+ delfunc R
+ delfunc Q
+ exe bufnr .. "bw!"
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab