diff --git a/pkg/vm/context.go b/pkg/vm/context.go index e682cda1b..9acd355d3 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -35,8 +35,8 @@ type Context struct { local *Slot arguments *Slot - // Exception context stack pointer. - tryStack *Stack + // Exception context stack. + tryStack Stack // Script hash of the prog. scriptHash util.Uint160 diff --git a/pkg/vm/stack.go b/pkg/vm/stack.go index 659ff0191..5dbe31e6d 100644 --- a/pkg/vm/stack.go +++ b/pkg/vm/stack.go @@ -171,6 +171,7 @@ func initStack(s *Stack, n string, refc *refCounter) { s.refs = refc s.top.next = &s.top s.top.prev = &s.top + s.len = 0 } // Clear clears all elements on the stack and set its length to 0. diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 2f973ed25..3ad7b11a6 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -282,7 +282,7 @@ func (v *VM) LoadScriptWithFlags(b []byte, f callflag.CallFlag) { ctx := NewContextWithParams(b, 0, -1, 0) v.estack = newStack("evaluation", &v.refs) ctx.estack = v.estack - ctx.tryStack = newStack("exception", nil) + initStack(&ctx.tryStack, "exception", nil) ctx.callFlag = f ctx.static = newSlot(&v.refs) ctx.callingScriptHash = v.GetCurrentScriptHash() @@ -1519,7 +1519,7 @@ func (v *VM) call(ctx *Context, offset int) { newCtx.RetCount = -1 newCtx.local = nil newCtx.arguments = nil - newCtx.tryStack = newStack("exception", nil) + initStack(&newCtx.tryStack, "exception", nil) newCtx.NEF = ctx.NEF v.istack.PushVal(newCtx) v.Jump(newCtx, offset)