Browse Source

Merge pull request #95 from tendermint/vm_panics

label/remove panics in vm
pull/102/head
Jae Kwon 10 years ago
parent
commit
99b94022ee
3 changed files with 5 additions and 1 deletions
  1. +2
    -0
      vm/native.go
  2. +1
    -0
      vm/stack.go
  3. +2
    -1
      vm/vm.go

+ 2
- 0
vm/native.go View File

@ -52,6 +52,7 @@ func sha256Func(input []byte, gas *int64) (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 *int64) (output []byte, err error) {
}
// Hash
hasher := ripemd160.New()
// CONTRACT: this does not err
_, err = hasher.Write(input)
if err != nil {
panic(err)


+ 1
- 0
vm/stack.go 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")


+ 2
- 1
vm/vm.go View File

@ -100,6 +100,7 @@ func (vm *VM) Call(caller, callee *Account, code, input []byte, value int64, gas
*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 int64, gas
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++


Loading…
Cancel
Save