From 27ff638eb6a3ccc37be923d309b35f34da1c3758 Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Thu, 11 Dec 2025 15:50:00 +0800 Subject: [PATCH] Correctly implementing the Dispose Pattern --- src/Neo.VM/ExecutionEngine.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Neo.VM/ExecutionEngine.cs b/src/Neo.VM/ExecutionEngine.cs index 3ec84101..0d1f8d69 100644 --- a/src/Neo.VM/ExecutionEngine.cs +++ b/src/Neo.VM/ExecutionEngine.cs @@ -103,12 +103,20 @@ protected ExecutionEngine(JumpTable? jumpTable, IReferenceCounter referenceCount ResultStack = new(referenceCounter); } - public virtual void Dispose() + public void Dispose() { - InvocationStack.Clear(); + Dispose(true); GC.SuppressFinalize(this); } + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + InvocationStack.Clear(); + } + } + /// /// Start execution of the VM. ///