0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.5117: crash when calling a Lua callback from a :def function

Problem:    Crash when calling a Lua callback from a :def function. (Bohdan
            Makohin)
Solution:   Handle FC_CFUNC in call_user_func_check(). (closes #10587)
This commit is contained in:
Bram Moolenaar
2022-06-17 19:23:34 +01:00
parent 47f1a55849
commit 7d149f899d
3 changed files with 22 additions and 8 deletions

View File

@@ -664,6 +664,17 @@ func Test_lua_blob()
\ '[string "vim chunk"]:1: string expected, got table') \ '[string "vim chunk"]:1: string expected, got table')
endfunc endfunc
def Vim9Test(Callback: func())
Callback()
enddef
func Test_call_lua_func_from_vim9_func()
" this only tests that Vim doesn't crash
lua << EOF
vim.fn.Vim9Test(function () print('Hello') end)
EOF
endfunc
func Test_lua_funcref() func Test_lua_funcref()
function I(x) function I(x)
return a:x return a:x

View File

@@ -3021,6 +3021,15 @@ call_user_func_check(
{ {
int error; int error;
#ifdef FEAT_LUA
if (fp->uf_flags & FC_CFUNC)
{
cfunc_T cb = fp->uf_cb;
return (*cb)(argcount, argvars, rettv, fp->uf_cb_state);
}
#endif
if (fp->uf_flags & FC_RANGE && funcexe->fe_doesrange != NULL) if (fp->uf_flags & FC_RANGE && funcexe->fe_doesrange != NULL)
*funcexe->fe_doesrange = TRUE; *funcexe->fe_doesrange = TRUE;
error = check_user_func_argcount(fp, argcount); error = check_user_func_argcount(fp, argcount);
@@ -3584,14 +3593,6 @@ call_func(
if (fp != NULL && (fp->uf_flags & FC_DELETED)) if (fp != NULL && (fp->uf_flags & FC_DELETED))
error = FCERR_DELETED; error = FCERR_DELETED;
#ifdef FEAT_LUA
else if (fp != NULL && (fp->uf_flags & FC_CFUNC))
{
cfunc_T cb = fp->uf_cb;
error = (*cb)(argcount, argvars, rettv, fp->uf_cb_state);
}
#endif
else if (fp != NULL) else if (fp != NULL)
{ {
if (funcexe->fe_argv_func != NULL) if (funcexe->fe_argv_func != NULL)

View File

@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
5117,
/**/ /**/
5116, 5116,
/**/ /**/