aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-30 08:27:38 +0800
committerGitHub <noreply@github.com>2023-04-30 08:27:38 +0800
commitab7dcefbebf5a483845e1fe1c82cb32e1c6418d4 (patch)
treed96eac819e8d6fb7a90983b62642544e923ca62c /test
parentc194acbfc479d8e5839fa629363f93f6550d035c (diff)
downloadrneovim-ab7dcefbebf5a483845e1fe1c82cb32e1c6418d4.tar.gz
rneovim-ab7dcefbebf5a483845e1fe1c82cb32e1c6418d4.tar.bz2
rneovim-ab7dcefbebf5a483845e1fe1c82cb32e1c6418d4.zip
vim-patch:9.0.1499: using uninitialized memory with fuzzy matching (#23399)
Problem: Using uninitialized memory with fuzzy matching. Solution: Initialize the arrays used to store match positions. https://github.com/vim/vim/commit/caf642c25de526229264cab9425e7c9979f3509b Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_matchfuzzy.vim27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/old/testdir/test_matchfuzzy.vim b/test/old/testdir/test_matchfuzzy.vim
index be5c629cf5..90f3366b23 100644
--- a/test/old/testdir/test_matchfuzzy.vim
+++ b/test/old/testdir/test_matchfuzzy.vim
@@ -2,6 +2,7 @@
source shared.vim
source check.vim
+source term_util.vim
" Test for matchfuzzy()
func Test_matchfuzzy()
@@ -260,4 +261,30 @@ func Test_matchfuzzy_limit()
call assert_equal([{'id': 5, 'val': 'crayon'}], l->matchfuzzy('c', #{key: 'val', limit: 1}))
endfunc
+" This was using uninitialized memory
+func Test_matchfuzzy_initialized()
+ CheckRunVimInTerminal
+
+ " This can take a very long time (esp. when using valgrind). Run in a
+ " separate Vim instance and kill it after two seconds. We only check for
+ " memory errors.
+ let lines =<< trim END
+ lvimgrep [ss [fg*
+ END
+ call writefile(lines, 'XTest_matchfuzzy', 'D')
+
+ let buf = RunVimInTerminal('-u NONE -X -Z', {})
+ call term_sendkeys(buf, ":source XTest_matchfuzzy\n")
+ call TermWait(buf, 2000)
+
+ let job = term_getjob(buf)
+ if job_status(job) == "run"
+ call job_stop(job, "int")
+ call TermWait(buf, 50)
+ endif
+
+ " clean up
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab