diff --git a/pkg/vm/stack.go b/pkg/vm/stack.go index 503c25571..b0eb41fc1 100644 --- a/pkg/vm/stack.go +++ b/pkg/vm/stack.go @@ -132,6 +132,14 @@ func newStack(n string, refc *refCounter) *Stack { initStack(s, n, refc) return s } + +func subStack(old *Stack) *Stack { + s := new(Stack) + *s = *old + s.elems = s.elems[len(s.elems):] + return s +} + func initStack(s *Stack, n string, refc *refCounter) { s.name = n s.refs = refc diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index c9843a48d..2ea18796b 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -322,7 +322,7 @@ func (v *VM) loadScriptWithCallingHash(b []byte, exe *nef.File, caller util.Uint v.checkInvocationStackSize() ctx := NewContextWithParams(b, rvcount, offset) if rvcount != -1 || v.estack.Len() != 0 { - v.estack = newStack("evaluation", &v.refs) + v.estack = subStack(v.estack) } ctx.estack = v.estack initStack(&ctx.tryStack, "exception", nil)