fix(api,lua): handle converting NULL funcref/partial (#37060)

This fixes the Coverity warnings.
This commit is contained in:
zeertzjq
2025-12-21 11:41:33 +08:00
committed by GitHub
parent f89558848b
commit acecdbff1f
2 changed files with 6 additions and 4 deletions

View File

@@ -76,8 +76,9 @@ static Object typval_cbuf_to_obj(EncodedData *edata, const char *data, size_t le
#define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun, prefix) \
do { \
ufunc_T *fp = find_func(fun); \
if (fp != NULL && (fp->uf_flags & FC_LUAREF)) { \
const char *const fun_ = (fun); \
ufunc_T *fp; \
if (fun_ != NULL && (fp = find_func(fun_)) != NULL && fp->uf_flags & FC_LUAREF) { \
kvi_push(edata->stack, LUAREF_OBJ(api_new_luaref(fp->uf_luaref))); \
} else { \
TYPVAL_ENCODE_CONV_NIL(tv); \

View File

@@ -455,8 +455,9 @@ static bool typval_conv_special = false;
#define TYPVAL_ENCODE_CONV_FUNC_START(tv, fun, prefix) \
do { \
ufunc_T *fp = find_func(fun); \
if (fp != NULL && fp->uf_flags & FC_LUAREF) { \
const char *const fun_ = (fun); \
ufunc_T *fp; \
if (fun_ != NULL && (fp = find_func(fun_)) != NULL && fp->uf_flags & FC_LUAREF) { \
nlua_pushref(lstate, fp->uf_luaref); \
} else { \
TYPVAL_ENCODE_CONV_NIL(tv); \