fix(api, lua): return NIL on failure to find converted function (#17779)

This commit is contained in:
zeertzjq
2022-03-20 08:08:50 +08:00
committed by GitHub
parent 2ab52bd988
commit 77eb6f9dc7
4 changed files with 47 additions and 4 deletions

View File

@@ -477,8 +477,7 @@ static bool typval_conv_special = false;
#define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun) \
do { \
ufunc_T *fp = find_func(fun); \
assert(fp != NULL); \
if (fp->uf_cb == nlua_CFunction_func_call) { \
if (fp != NULL && fp->uf_cb == nlua_CFunction_func_call) { \
nlua_pushref(lstate, ((LuaCFunctionState *)fp->uf_cb_state)->lua_callable.func_ref); \
} else { \
TYPVAL_ENCODE_CONV_NIL(tv); \