bugfix, See issue #1027

This commit is contained in:
Cloud Wu
2019-06-15 00:29:05 +08:00
parent 5a0f68999e
commit 6f0e88dc59
4 changed files with 12 additions and 4 deletions

View File

@@ -39,8 +39,12 @@ mark_shared(lua_State *L) {
case LUA_TLIGHTUSERDATA:
break;
case LUA_TFUNCTION:
if (!lua_iscfunction(L, idx) || lua_getupvalue(L, idx, 1) != NULL)
luaL_error(L, "Invalid function");
if (lua_getupvalue(L, idx, 1) != NULL) {
luaL_error(L, "Invalid function with upvalue");
} else if (!lua_iscfunction(L, idx)) {
LClosure *f = (LClosure *)lua_topointer(L, idx);
makeshared(f);
}
break;
case LUA_TSTRING:
lua_sharestring(L, idx);