From 9ecac14aee50ab608159afff5878f6be782f5c74 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 30 Apr 2020 19:19:31 +0300 Subject: [PATCH] vm: fix bug in GetContextScriptHash() v.Istack.Peek(n) can return nil pointer, so .Value() on this pointer leads to panic here. Fixed by adding nil check. --- pkg/vm/context.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/vm/context.go b/pkg/vm/context.go index 4d1b9c00e..14b039dfd 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -226,7 +226,11 @@ func (c *Context) String() string { // GetContextScriptHash returns script hash of the invocation stack element // number n. func (v *VM) GetContextScriptHash(n int) util.Uint160 { - ctxIface := v.Istack().Peek(n).Value() + element := v.Istack().Peek(n) + if element == nil { + return util.Uint160{} + } + ctxIface := element.Value() ctx := ctxIface.(*Context) return ctx.ScriptHash() }