Browse Source

vm: catch stack underflow on Peek()

pull/126/merge
Ethan Buchman 9 years ago
parent
commit
807bd662b2
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      vm/stack.go

+ 4
- 0
vm/stack.go View File

@ -104,6 +104,10 @@ func (st *Stack) Dup(n int) {
// Not an opcode, costs no gas. // Not an opcode, costs no gas.
func (st *Stack) Peek() Word256 { func (st *Stack) Peek() Word256 {
if st.ptr == 0 {
st.setErr(ErrDataStackUnderflow)
return Zero256
}
return st.data[st.ptr-1] return st.data[st.ptr-1]
} }


Loading…
Cancel
Save