diff --git a/src/Neo.VM/EvaluationStack.cs b/src/Neo.VM/EvaluationStack.cs
index 571cb6b2db..5c6c9da42c 100644
--- a/src/Neo.VM/EvaluationStack.cs
+++ b/src/Neo.VM/EvaluationStack.cs
@@ -107,11 +107,12 @@ public StackItem Peek(int index = 0)
/// Pushes an item onto the top of the stack.
///
/// The item to be pushed.
+ /// Stack reference count addition. For OpCodes loading from slot to evaluation stack, it can be 0.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void Push(StackItem item)
+ public void Push(StackItem item, int count = 1)
{
innerList.Add(item);
- referenceCounter.AddStackReference(item);
+ referenceCounter.AddStackReference(item, count: count);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/Neo.VM/ExecutionEngine.cs b/src/Neo.VM/ExecutionEngine.cs
index bec60c4348..d53512f7b1 100644
--- a/src/Neo.VM/ExecutionEngine.cs
+++ b/src/Neo.VM/ExecutionEngine.cs
@@ -302,10 +302,11 @@ protected virtual void PreExecuteInstruction(Instruction instruction) { }
/// Pushes an item onto the top of the current stack.
///
/// The item to be pushed.
+ /// Stack reference count addition. For OpCodes loading from slot to evaluation stack, it can be 0.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void Push(StackItem item)
+ public void Push(StackItem item, int count = 1)
{
- CurrentContext!.EvaluationStack.Push(item);
+ CurrentContext!.EvaluationStack.Push(item, count: count);
}
}
}
diff --git a/src/Neo.VM/JumpTable/JumpTable.Slot.cs b/src/Neo.VM/JumpTable/JumpTable.Slot.cs
index 22214924cf..6adc8e58c3 100644
--- a/src/Neo.VM/JumpTable/JumpTable.Slot.cs
+++ b/src/Neo.VM/JumpTable/JumpTable.Slot.cs
@@ -675,7 +675,7 @@ public virtual void ExecuteLoadFromSlot(ExecutionEngine engine, Slot? slot, int
throw new InvalidOperationException("Slot has not been initialized.");
if (index < 0 || index >= slot.Count)
throw new InvalidOperationException($"Index out of range when loading from slot: {index}");
- engine.Push(slot[index]);
+ engine.Push(slot[index], count: 0);
}
#endregion