From df98ba391a3e52df3b653cefb9d66964c35b733a Mon Sep 17 00:00:00 2001 From: Martin Holst Swende Date: Mon, 4 Mar 2019 11:39:20 +0100 Subject: [PATCH] core/vm: use generic error message for jump/jumpi, to avoid string interpolation --- core/vm/instructions.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/vm/instructions.go b/core/vm/instructions.go index 04ecea4718..0cdafff416 100644 --- a/core/vm/instructions.go +++ b/core/vm/instructions.go @@ -18,7 +18,6 @@ package vm import ( "errors" - "fmt" "math/big" "github.com/ethereum/go-ethereum/common" @@ -35,6 +34,7 @@ var ( errReturnDataOutOfBounds = errors.New("evm: return data out of bounds") errExecutionReverted = errors.New("evm: execution reverted") errMaxCodeSizeExceeded = errors.New("evm: max code size exceeded") + errInvalidJump = errors.New("evm: invalid jump destination") ) func opAdd(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { @@ -645,8 +645,7 @@ func opSstore(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memor func opJump(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) { pos := stack.pop() if !contract.validJumpdest(pos) { - nop := contract.GetOp(pos.Uint64()) - return nil, fmt.Errorf("invalid jump destination (%v) %v", nop, pos) + return nil, errInvalidJump } *pc = pos.Uint64() @@ -658,8 +657,7 @@ func opJumpi(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memory pos, cond := stack.pop(), stack.pop() if cond.Sign() != 0 { if !contract.validJumpdest(pos) { - nop := contract.GetOp(pos.Uint64()) - return nil, fmt.Errorf("invalid jump destination (%v) %v", nop, pos) + return nil, errInvalidJump } *pc = pos.Uint64() } else {