label/remove panics in vm

This commit is contained in:
Ethan Buchman
2015-06-26 01:50:31 +00:00
parent 6a0223641f
commit 8f94997472
3 changed files with 5 additions and 1 deletions

View File

@ -52,6 +52,7 @@ func sha256Func(input []byte, gas *uint64) (output []byte, err error) {
}
// Hash
hasher := sha256.New()
// CONTRACT: this does not err
_, err = hasher.Write(input)
if err != nil {
panic(err)
@ -69,6 +70,7 @@ func ripemd160Func(input []byte, gas *uint64) (output []byte, err error) {
}
// Hash
hasher := ripemd160.New()
// CONTRACT: this does not err
_, err = hasher.Write(input)
if err != nil {
panic(err)

View File

@ -47,6 +47,7 @@ func (st *Stack) Push(d Word256) {
st.ptr++
}
// currently only called after Sha3
func (st *Stack) PushBytes(bz []byte) {
if len(bz) != 32 {
panic("Invalid bytes size: expected 32")

View File

@ -100,6 +100,7 @@ func (vm *VM) Call(caller, callee *Account, code, input []byte, value uint64, ga
*exception = err.Error()
err := transfer(callee, caller, value)
if err != nil {
// data has been corrupted in ram
panic("Could not return value to caller")
}
}
@ -784,7 +785,7 @@ func (vm *VM) call(caller, callee *Account, code, input []byte, value uint64, ga
default:
dbg.Printf("(pc) %-3v Invalid opcode %X\n", pc, op)
panic(fmt.Errorf("Invalid opcode %X", op))
return nil, fmt.Errorf("Invalid opcode %X", op)
}
pc++