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)

cf2594fbf3

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2025-07-17 16:48:56 +08:00
parent 4f0ab9877b
commit 5671b61327

View File

@@ -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