Stack limit

This commit is contained in:
obscuren 2015-03-26 17:45:09 +01:00
parent d36501a6e5
commit c32bca45ad

@ -5,6 +5,8 @@ import (
"math/big"
)
const maxStack = 1024
func newStack() *stack {
return &stack{}
}
@ -15,6 +17,10 @@ type stack struct {
}
func (st *stack) push(d *big.Int) {
if len(st.data) == maxStack {
panic(fmt.Sprintf("stack limit reached (%d)", maxStack))
}
stackItem := new(big.Int).Set(d)
if len(st.data) > st.ptr {
st.data[st.ptr] = stackItem