浏览代码

Fix: unintended `index out of range exception` on other exception

Akeit0 10 月之前
父节点
当前提交
005ff07031
共有 1 个文件被更改,包括 4 次插入2 次删除
  1. 4 2
      src/Lua/Runtime/LuaVirtualMachine.cs

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

@@ -932,16 +932,18 @@ public static partial class LuaVirtualMachine
         }
         }
         catch (Exception e)
         catch (Exception e)
         {
         {
-            context.PopOnTopCallStackFrames();
+            
             context.State.CloseUpValues(context.Thread, context.FrameBase);
             context.State.CloseUpValues(context.Thread, context.FrameBase);
             LuaValueArrayPool.Return1024(context.ResultsBuffer, true);
             LuaValueArrayPool.Return1024(context.ResultsBuffer, true);
             if (e is not LuaRuntimeException)
             if (e is not LuaRuntimeException)
             {
             {
-                var newException = new LuaRuntimeException(GetTracebacks(ref context), e);
+                var newException = new LuaRuntimeException(context.State.GetTraceback(), e);
                 context = default;
                 context = default;
+                context.PopOnTopCallStackFrames();
                 throw newException;
                 throw newException;
             }
             }
 
 
+            context.PopOnTopCallStackFrames();
             throw;
             throw;
         }
         }
     }
     }