From 5671b61327bf570ccc232b4a6f164c077eaa5bcb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 17 Jul 2025 16:48:56 +0800 Subject: [PATCH] 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 --- test/old/testdir/test_usercommands.vim | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/old/testdir/test_usercommands.vim b/test/old/testdir/test_usercommands.vim index c4bc45aa3d..046e0b1874 100644 --- 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 in user defined commands function Test_cmdmods() let g:mods = '' @@ -362,6 +365,14 @@ func Test_CmdCompletion() call feedkeys(":com MyCmd chist\\\"\", 'tx') call assert_equal("\"com MyCmd chistory", @:) + " delete the Check commands to avoid them showing up + call feedkeys(":com Check\\\"\", 'tx') + let cmds = substitute(@:, '"com ', '', '')->split() + for cmd in cmds + exe 'delcommand ' .. cmd + endfor + delcommand MissingFeature + command! DoCmd1 : command! DoCmd2 : call feedkeys(":com \\\"\", '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