From 4f707e498c85ff6c193bd917e454b6997fa0673b Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 6 Feb 2025 08:36:28 +0100 Subject: [PATCH] Lua: Reject setting metatable to a nil value --- common/space_lua/stdlib.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/space_lua/stdlib.ts b/common/space_lua/stdlib.ts index ca3d0ee3..a993f7fd 100644 --- a/common/space_lua/stdlib.ts +++ b/common/space_lua/stdlib.ts @@ -124,7 +124,10 @@ const xpcallFunction = new LuaBuiltinFunction( ); const setmetatableFunction = new LuaBuiltinFunction( - (_sf, table: LuaTable, metatable: LuaTable) => { + (sf, table: LuaTable, metatable: LuaTable) => { + if (!metatable) { + throw new LuaRuntimeError("metatable cannot be set to nil", sf); + } table.metatable = metatable; return table; },