commit 5671b61327bf570ccc232b4a6f164c077eaa5bcb
parent 4f0ab9877bef18d78714a2517dd2165c712a0be0
Author: zeertzjq <zeertzjq@outlook.com>
Date: Thu, 17 Jul 2025 16:48:56 +0800
vim-patch:partial:9.0.0877: using freed memory with :comclear while listing commands
Problem: Using freed memory with :comclear while listing commands.
Solution: Bail out when the command list has changed. (closes vim/vim#11440)
https://github.com/vim/vim/commit/cf2594fbf34d9a6776bd9d33f845cb8ceb1e1cd0
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/test/old/testdir/test_usercommands.vim b/test/old/testdir/test_usercommands.vim
@@ -1,5 +1,8 @@
" Tests for user defined commands
+source check.vim
+source screendump.vim
+
" Test for <mods> in user defined commands
function Test_cmdmods()
let g:mods = ''
@@ -362,6 +365,14 @@ func Test_CmdCompletion()
call feedkeys(":com MyCmd chist\<Tab>\<C-B>\"\<CR>", 'tx')
call assert_equal("\"com MyCmd chistory", @:)
+ " delete the Check commands to avoid them showing up
+ call feedkeys(":com Check\<C-A>\<C-B>\"\<CR>", 'tx')
+ let cmds = substitute(@:, '"com ', '', '')->split()
+ for cmd in cmds
+ exe 'delcommand ' .. cmd
+ endfor
+ delcommand MissingFeature
+
command! DoCmd1 :
command! DoCmd2 :
call feedkeys(":com \<C-A>\<C-B>\"\<CR>", 'tx')
@@ -715,7 +726,7 @@ func Test_recursive_define()
call DefCmd('Command')
let name = 'Command'
- while len(name) < 30
+ while len(name) <= 30
exe 'delcommand ' .. name
let name ..= 'x'
endwhile