Skip to content

Commit

Permalink
make lua_obj optional
Browse files Browse the repository at this point in the history
so that printing a function would not cause crash
  • Loading branch information
tony2001 committed May 24, 2019
1 parent ef70d19 commit 13e26a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 0 additions & 5 deletions lua.c
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion lua_closure.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 13e26a3

Please sign in to comment.