diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2025-02-02 16:00:04 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2025-02-03 11:27:56 +0800 |
| commit | 82ac8294c22a15899548a1cb408ca114a598f434 (patch) | |
| tree | d943adb6b56dd29638207ab335c87cdc7e3f6906 /test | |
| parent | b853ef770a25fcd91def6c5016d65c336897c2cc (diff) | |
| download | rneovim-82ac8294c22a15899548a1cb408ca114a598f434.tar.gz rneovim-82ac8294c22a15899548a1cb408ca114a598f434.tar.bz2 rneovim-82ac8294c22a15899548a1cb408ca114a598f434.zip | |
vim-patch:9.1.1066: heap-use-after-free and stack-use-after-scope with :14verbose
Problem: heap-use-after-free and stack-use-after-scope with :14verbose
when using :return and :try (after 9.1.1063).
Solution: Move back the vim_free(tofree) and the scope of numbuf[].
(zeertzjq)
closes: vim/vim#16563
https://github.com/vim/vim/commit/2101230f4013860dbafcb0cab3f4e6bc92fb6f35
Diffstat (limited to 'test')
| -rw-r--r-- | test/old/testdir/test_user_func.vim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/old/testdir/test_user_func.vim b/test/old/testdir/test_user_func.vim index b509b03778..da6a6d8dc4 100644 --- a/test/old/testdir/test_user_func.vim +++ b/test/old/testdir/test_user_func.vim @@ -910,4 +910,36 @@ func Test_func_curly_brace_invalid_name() delfunc Fail endfunc +func Test_func_return_in_try_verbose() + func TryReturnList() + try + return [1, 2, 3] + endtry + endfunc + func TryReturnNumber() + try + return 123 + endtry + endfunc + func TryReturnOverlongString() + try + return repeat('a', 9999) + endtry + endfunc + + " This should not cause heap-use-after-free + call assert_match('\n:return \[1, 2, 3\] made pending\n', + \ execute('14verbose call TryReturnList()')) + " This should not cause stack-use-after-scope + call assert_match('\n:return 123 made pending\n', + \ execute('14verbose call TryReturnNumber()')) + " An overlong string is truncated + call assert_match('\n:return a\{100,}\.\.\.', + \ execute('14verbose call TryReturnOverlongString()')) + + delfunc TryReturnList + delfunc TryReturnNumber + delfunc TryReturnOverlongString +endfunc + " vim: shiftwidth=2 sts=2 expandtab |