From 13e26a383a6879061bb0e80500511a9e6b263b4d Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Fri, 24 May 2019 12:23:58 +0300 Subject: [PATCH] make lua_obj optional so that printing a function would not cause crash --- lua.c | 5 ----- lua_closure.c | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lua.c b/lua.c index 0e5cde1..92f89f2 100755 --- a/lua.c +++ b/lua.c @@ -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); diff --git a/lua_closure.c b/lua_closure.c index 90f92a4..50ef039 100644 --- a/lua_closure.c +++ b/lua_closure.c @@ -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; }