import './util/vim9.vim' as v9
source util/screendump.vim
+source util/shared.vim
func Test_def_basic()
def SomeFunc(): string
v9.CheckScriptFailure(lines, 'E1186: Expression does not result in a value: bufload(')
enddef
+def Test_term_wait_in_job_exit_cb()
+ CheckUnix
+ CheckFeature terminal
+
+ var cmd = g:GetVimCommand()
+
+ var lines =<< eval trim END
+ var buf: number = term_start(["{cmd}", "+q"], {{}})
+
+ var job: job = term_getjob(buf)
+
+ job_setoptions(job, {{
+ exit_cb: (_, _) => {{
+ term_wait(buf)
+ }}
+ }})
+ END
+
+ # This shouldn't cause an ASAN error immediately, but will result in a use
+ # after free when Vim exits.
+ v9.CheckDefSuccess(lines)
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
void
unlink_def_function(ufunc_T *ufunc)
{
- if (ufunc->uf_dfunc_idx <= 0)
+ if (ufunc->uf_dfunc_idx <= 0 || def_functions.ga_data == NULL)
return;
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)