From dea94c669bbfe28b2fa360c167cefcc1a63bdef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 16 Oct 2014 13:49:13 +0200 Subject: [PATCH] Throw BadInstruction exception in FeeStructure::getInstructionFee() when instruction code is ivalid --- libevm/FeeStructure.cpp | 8 ++++++-- libevm/FeeStructure.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libevm/FeeStructure.cpp b/libevm/FeeStructure.cpp index 661f7af6f..aeeb19e27 100644 --- a/libevm/FeeStructure.cpp +++ b/libevm/FeeStructure.cpp @@ -24,18 +24,22 @@ #include +#include "VM.h" + namespace dev { namespace eth { -uint32_t FeeStructure::getInstructionFee(Instruction _inst) BOOST_NOEXCEPT_OR_NOTHROW +uint32_t FeeStructure::getInstructionFee(Instruction _inst) { switch (_inst) { + default: + BOOST_THROW_EXCEPTION(BadInstruction()); + case Instruction::STOP: case Instruction::SUICIDE: - default: // In case of bad instruction return 0 return 0; case Instruction::SSTORE: diff --git a/libevm/FeeStructure.h b/libevm/FeeStructure.h index 73ea48156..8591afa14 100644 --- a/libevm/FeeStructure.h +++ b/libevm/FeeStructure.h @@ -45,8 +45,8 @@ struct FeeStructure static uint32_t const c_txGas = 500; ///< Per transaction. NOTE: Not payable on data of calls between transactions. /// Returns step fee of the instruction. - /// In case of bad instruction code, returns 0. - static uint32_t getInstructionFee(Instruction _inst) BOOST_NOEXCEPT_OR_NOTHROW; + /// In case of bad instruction code, throws BadInstruction exception. + static uint32_t getInstructionFee(Instruction _inst); }; }