make lua_obj optional

so that printing a function would not cause crash
This commit is contained in:
Antony Dovgal
2019-05-24 12:23:58 +03:00
parent ef70d19a33
commit 13e26a383a
2 changed files with 3 additions and 6 deletions

5
lua.c
View File

@@ -355,11 +355,6 @@ zval *php_lua_get_zval_from_lua(lua_State *L, int index, zval *lua_obj, zval *rv
case LUA_TFUNCTION:
{
long ref_id = 0;
if (!lua_obj) {
php_error_docref(NULL, E_WARNING, "corrupted Lua object");
break;
}
lua_pushvalue(L, index);
ref_id = luaL_ref(L, LUA_REGISTRYINDEX);

View File

@@ -53,7 +53,9 @@ zval* php_lua_closure_instance(zval *instance, long ref_id, zval *lua_obj) {
object_init_ex(instance, lua_closure_ce);
objval = php_lua_closure_object_from_zend_object(Z_OBJ_P(instance));
objval->closure = ref_id;
ZVAL_ZVAL(&(objval->lua), lua_obj, 1, 0);
if (lua_obj) {
ZVAL_ZVAL(&(objval->lua), lua_obj, 1, 0);
}
return instance;
}