aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvalid-ptr <konstantin.matveyev@eligovision.ru>2021-02-15 16:24:54 +0300
committerkonstantin.matveyev <konstantin.matveyev@eligovision.ru>2021-02-15 16:30:27 +0300
commit1d255d1d5f55584626ae247610f379ccdb8f2ec5 (patch)
tree99418cf0c07e06def1b53853e7701f88e241e43b
parent203790a68020186bf668b2787968aa0d901fc518 (diff)
downloadlanes-1d255d1d5f55584626ae247610f379ccdb8f2ec5.tar.gz
lanes-1d255d1d5f55584626ae247610f379ccdb8f2ec5.tar.bz2
lanes-1d255d1d5f55584626ae247610f379ccdb8f2ec5.zip
Bug fix for Lua 5.1/LuaJIT: lua_getiuservalue must check if lua_getfenv returns global environment
-rw-r--r--src/compat.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/compat.c b/src/compat.c
index 9f36090..bccd05f 100644
--- a/src/compat.c
+++ b/src/compat.c
@@ -59,6 +59,20 @@ int lua_getiuservalue( lua_State* L, int idx, int n)
59 return LUA_TNONE; 59 return LUA_TNONE;
60 } 60 }
61 lua_getuservalue( L, idx); 61 lua_getuservalue( L, idx);
62
63#if LUA_VERSION_NUM == 501
64 /* default environment is not a nil (see lua_getfenv) */
65 lua_getglobal(L, "package");
66 if (lua_rawequal(L, -2, -1) || lua_rawequal(L, -2, LUA_GLOBALSINDEX))
67 {
68 lua_pop(L, 2);
69 lua_pushnil( L);
70
71 return LUA_TNONE;
72 }
73 lua_pop(L, 1); /* remove package */
74#endif
75
62 return lua_type( L, -1); 76 return lua_type( L, -1);
63} 77}
64 78