Browse Source

Fix: table NaN index

AnnulusGames 1 year ago
parent
commit
d7dd28d18b
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Lua/Runtime/LuaVirtualMachine.cs

+ 5 - 0
src/Lua/Runtime/LuaVirtualMachine.cs

@@ -959,6 +959,11 @@ public static partial class LuaVirtualMachine
         var stack = state.CurrentThread.Stack;
         var isTable = table.TryRead<LuaTable>(out var t);
 
+        if (key.Type is LuaValueType.Number && key.TryRead<double>(out var d) && double.IsNaN(d))
+        {
+            throw new LuaRuntimeException(GetTracebacks(state, chunk, pc), "table index is NaN");
+        }
+
         if (isTable && t.ContainsKey(key))
         {
             t[key] = value;