From eceeb15ee574abd223dbd65bdf19a1a763882b28 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Tue, 14 Feb 2023 09:43:24 +0100 Subject: [PATCH] Fix bug in lua_ui/content.lua: getmetatable(ui.content{}) shouldn't return a global mutable table --- apps/openmw_test_suite/lua/test_ui_content.cpp | 2 +- components/lua_ui/content.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw_test_suite/lua/test_ui_content.cpp b/apps/openmw_test_suite/lua/test_ui_content.cpp index bf33bbd697..01a5cdd370 100644 --- a/apps/openmw_test_suite/lua/test_ui_content.cpp +++ b/apps/openmw_test_suite/lua/test_ui_content.cpp @@ -42,7 +42,7 @@ namespace mLuaState.sol()["M"] = makeContent(makeTable()).getMetatable(); std::string testScript = R"( assert(not pcall(function() setmetatable(makeContent{}, {}) end), 'Metatable is not protected') - assert(getmetatable(makeContent{}) ~= M, 'Metatable is not protected') + assert(getmetatable(makeContent{}) == false, 'Metatable is not protected') )"; EXPECT_NO_THROW(mLuaState.sol().safe_script(testScript)); } diff --git a/components/lua_ui/content.lua b/components/lua_ui/content.lua index cd63efc7ca..fbd39d5f68 100644 --- a/components/lua_ui/content.lua +++ b/components/lua_ui/content.lua @@ -135,6 +135,6 @@ M.__pairs = function(self) return next, self, 1 end M.__ipairs = M.__pairs -M.__metatable = {} +M.__metatable = false return M