1
0
forked from aniani/vim

patch 8.2.3779: using freed memory when defining a user command recursively

Problem:    Using freed memory when defining a user command from a user
            command.
Solution:   Do not use the command pointer after executing the command.
            (closes #9318)
This commit is contained in:
Bram Moolenaar
2021-12-10 21:46:09 +00:00
parent 9537e37b11
commit 205f29c3e9
3 changed files with 30 additions and 2 deletions

View File

@@ -704,5 +704,24 @@ def Test_count_with_quotes()
delcommand GetCount
enddef
func DefCmd(name)
if len(a:name) > 30
return
endif
exe 'command ' .. a:name .. ' call DefCmd("' .. a:name .. 'x")'
echo a:name
exe a:name
endfunc
func Test_recursive_define()
call DefCmd('Command')
let name = 'Command'
while len(name) < 30
exe 'delcommand ' .. name
let name ..= 'x'
endwhile
endfunc
" vim: shiftwidth=2 sts=2 expandtab