Browse Source

Fix: LuaStack.PopUntil

AnnulusGames 1 year ago
parent
commit
3e808e250e
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/Lua/Runtime/LuaStack.cs

+ 8 - 1
src/Lua/Runtime/LuaStack.cs

@@ -52,7 +52,14 @@ public class LuaStack(int initialSize = 256)
     public void PopUntil(int newSize)
     public void PopUntil(int newSize)
     {
     {
         if (newSize >= top) return;
         if (newSize >= top) return;
-        array.AsSpan(newSize, top).Clear();
+        if (newSize == 0)
+        {
+            array.AsSpan().Clear();
+        }
+        else
+        {
+            array.AsSpan(newSize - 1).Clear();
+        }
         top = newSize;
         top = newSize;
     }
     }