AnnulusGames 1 year ago
parent
commit
aaed14e3cc
1 changed files with 11 additions and 4 deletions
  1. 11 4
      src/Lua/Runtime/LuaVirtualMachine.cs

+ 11 - 4
src/Lua/Runtime/LuaVirtualMachine.cs

@@ -696,12 +696,19 @@ public static partial class LuaVirtualMachine
                                 resultCount = instruction.C - 1;
                             }
 
-                            stack.EnsureCapacity(RA + resultCount);
-                            for (int i = 0; i < resultCount; i++)
+                            if (resultCount == 0)
                             {
-                                stack.UnsafeGet(RA + i) = resultBuffer[i];
+                                stack.Pop();
+                            }
+                            else
+                            {
+                                stack.EnsureCapacity(RA + resultCount);
+                                for (int i = 0; i < resultCount; i++)
+                                {
+                                    stack.UnsafeGet(RA + i) = resultBuffer[i];
+                                }
+                                stack.NotifyTop(RA + resultCount);
                             }
-                            stack.NotifyTop(RA + resultCount);
                         }
                         finally
                         {