comparison src/testdir/test_functions.vim @ 31081:c12069d28719 v9.0.0875

patch 9.0.0875: using freed memory when executing delfunc at more prompt Commit: https://github.com/vim/vim/commit/398a26f7fcd58fbc6e2329f892edbb7479a971bb Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 13 22:13:33 2022 +0000 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 https://github.com/vim/vim/issues/11437)
author Bram Moolenaar <Bram@vim.org>
date Sun, 13 Nov 2022 23:15:03 +0100
parents 1a32f1a4f823
children 004aee2845d2
comparison
equal deleted inserted replaced
31080:df91dcf490f2 31081:c12069d28719
3024 call assert_equal(8, virtcol('.', v:false)) 3024 call assert_equal(8, virtcol('.', v:false))
3025 call assert_equal([4, 8], virtcol('.', v:true)) 3025 call assert_equal([4, 8], virtcol('.', v:true))
3026 bwipe! 3026 bwipe!
3027 endfunc 3027 endfunc
3028 3028
3029 func Test_delfunc_while_listing()
3030 CheckRunVimInTerminal
3031
3032 let lines =<< trim END
3033 set nocompatible
3034 for i in range(1, 999)
3035 exe 'func ' .. 'MyFunc' .. i .. '()'
3036 endfunc
3037 endfor
3038 au CmdlineLeave : call timer_start(0, {-> execute('delfunc MyFunc622')})
3039 END
3040 call writefile(lines, 'Xfunctionclear', 'D')
3041 let buf = RunVimInTerminal('-S Xfunctionclear', {'rows': 12})
3042
3043 " This was using freed memory. The height of the terminal must be so that
3044 " the next function to be listed with "j" is the one that is deleted in the
3045 " timer callback, tricky!
3046 call term_sendkeys(buf, ":func /MyFunc\<CR>")
3047 call TermWait(buf, 50)
3048 call term_sendkeys(buf, "j")
3049 call TermWait(buf, 50)
3050 call term_sendkeys(buf, "\<CR>")
3051
3052 call StopVimInTerminal(buf)
3053 endfunc
3054
3055
3029 " vim: shiftwidth=2 sts=2 expandtab 3056 " vim: shiftwidth=2 sts=2 expandtab