From 13ebad4be59e4f2c706202045f9f266a69c3d3ec Mon Sep 17 00:00:00 2001
From: Hecate2 <2474101468@qq.com>
Date: Wed, 9 Oct 2024 15:11:39 +0800
Subject: [PATCH] handle https://github.com/neo-project/neo/pull/3520
---
src/Neo.VM/EvaluationStack.cs | 5 +++--
src/Neo.VM/ExecutionEngine.cs | 5 +++--
src/Neo.VM/JumpTable/JumpTable.Slot.cs | 2 +-
3 files changed, 7 insertions(+), 5 deletions(-)
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