From 807bd662b2d70e578185ad284b39ae16c73a6dcc Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sat, 8 Aug 2015 22:20:19 -0400 Subject: [PATCH] vm: catch stack underflow on Peek() --- vm/stack.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vm/stack.go b/vm/stack.go index 9dfff4df6..7dae3e71d 100644 --- a/vm/stack.go +++ b/vm/stack.go @@ -104,6 +104,10 @@ func (st *Stack) Dup(n int) { // Not an opcode, costs no gas. func (st *Stack) Peek() Word256 { + if st.ptr == 0 { + st.setErr(ErrDataStackUnderflow) + return Zero256 + } return st.data[st.ptr-1] }