0
0
mirror of https://github.com/vim/vim.git synced 2025-09-28 04:24:06 -04:00

patch 9.0.0875: using freed memory when executing delfunc at more prompt

Problem:    Using freed memory when executing delfunc at the more prompt.
Solution:   Check function list not changed in another place. (closes #11437)
This commit is contained in:
Bram Moolenaar
2022-11-13 22:13:33 +00:00
parent 920d311480
commit 398a26f7fc
3 changed files with 89 additions and 28 deletions

View File

@@ -3026,4 +3026,31 @@ func Test_virtcol()
bwipe!
endfunc
func Test_delfunc_while_listing()
CheckRunVimInTerminal
let lines =<< trim END
set nocompatible
for i in range(1, 999)
exe 'func ' .. 'MyFunc' .. i .. '()'
endfunc
endfor
au CmdlineLeave : call timer_start(0, {-> execute('delfunc MyFunc622')})
END
call writefile(lines, 'Xfunctionclear', 'D')
let buf = RunVimInTerminal('-S Xfunctionclear', {'rows': 12})
" This was using freed memory. The height of the terminal must be so that
" the next function to be listed with "j" is the one that is deleted in the
" timer callback, tricky!
call term_sendkeys(buf, ":func /MyFunc\<CR>")
call TermWait(buf, 50)
call term_sendkeys(buf, "j")
call TermWait(buf, 50)
call term_sendkeys(buf, "\<CR>")
call StopVimInTerminal(buf)
endfunc
" vim: shiftwidth=2 sts=2 expandtab