summaryrefslogtreecommitdiff
path: root/libs/lua
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-03-30 05:06:34 +0200
committerRobin Gareus <robin@gareus.org>2017-03-30 05:06:34 +0200
commitea8c6e9fc81fb4a5bf44e6c2d5a3506b52e530e1 (patch)
tree4f8c31dce0f93dedfec1ecf0699a1a6b3fdfca1f /libs/lua
parent33b859a807739fe0c27282827a7cf564b7240d2e (diff)
Fix hiding Lua __metatable -- prevent setmetatable() override
Diffstat (limited to 'libs/lua')
-rw-r--r--libs/lua/LuaBridge/detail/Namespace.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/libs/lua/LuaBridge/detail/Namespace.h b/libs/lua/LuaBridge/detail/Namespace.h
index a8e190da43..5ea139ee22 100644
--- a/libs/lua/LuaBridge/detail/Namespace.h
+++ b/libs/lua/LuaBridge/detail/Namespace.h
@@ -363,7 +363,7 @@ private:
if (Security::hideMetatables ())
{
- lua_pushnil (L);
+ lua_pushboolean (L, false);
rawsetfield (L, -2, "__metatable");
}
}
@@ -400,7 +400,7 @@ private:
if (Security::hideMetatables ())
{
- lua_pushnil (L);
+ lua_pushboolean (L, false);
rawsetfield (L, -2, "__metatable");
}
}
@@ -442,7 +442,7 @@ private:
if (Security::hideMetatables ())
{
- lua_pushnil (L);
+ lua_pushboolean (L, false);
rawsetfield (L, -2, "__metatable");
}
}
@@ -1161,8 +1161,14 @@ private:
lua_setfield(L, -2, "__index");
lua_pushcclosure (L, CFunc::array_newindex<T>, 0);
lua_setfield(L, -2, "__newindex");
+ if (Security::hideMetatables ())
+ {
+ lua_pushboolean (L, false);
+ rawsetfield (L, -2, "__metatable");
+ }
lua_pop (L, 1);
+
createConstTable (name);
lua_pushcfunction (L, &CFunc::gcMetaMethod <T>);
rawsetfield (L, -2, "__gc");
@@ -1532,6 +1538,12 @@ private:
lua_pushcfunction (L, &tostringMetaMethod);
rawsetfield (L, -2, "__tostring");
#endif
+ if (Security::hideMetatables ())
+ {
+ lua_pushboolean (L, false);
+ rawsetfield (L, -2, "__metatable");
+ }
+
}
}