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.
This commit is contained in:
Anna Shaleva 2020-04-30 19:19:31 +03:00
parent d1ec01c45e
commit 9ecac14aee

View file

@ -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()
}