diff --git a/mythril/laser/ethereum/evm_exceptions.py b/mythril/laser/ethereum/evm_exceptions.py index 7e2a7b8f..647c52e4 100644 --- a/mythril/laser/ethereum/evm_exceptions.py +++ b/mythril/laser/ethereum/evm_exceptions.py @@ -41,9 +41,3 @@ class WriteProtection(VmException): """A VM exception denoting that a write operation is executed on a write protected environment""" pass - - -class ProgramCounterException(VmException): - """A VM exception denoting an invalid PC value (No stop instruction is reached).""" - - pass diff --git a/mythril/laser/ethereum/state/global_state.py b/mythril/laser/ethereum/state/global_state.py index 5096516e..0e15209d 100644 --- a/mythril/laser/ethereum/state/global_state.py +++ b/mythril/laser/ethereum/state/global_state.py @@ -9,7 +9,6 @@ from mythril.laser.ethereum.cfg import Node from mythril.laser.ethereum.state.environment import Environment from mythril.laser.ethereum.state.machine_state import MachineState from mythril.laser.ethereum.state.annotation import StateAnnotation -from mythril.laser.ethereum.evm_exceptions import ProgramCounterException if TYPE_CHECKING: from mythril.laser.ethereum.state.world_state import WorldState @@ -95,13 +94,12 @@ class GlobalState: :return: """ - instructions = self.environment.code.instruction_list - if self.mstate.pc >= len(instructions): - raise ProgramCounterException( - "PC: {} can not be reached.".format(self.mstate.pc) - ) - return instructions[self.mstate.pc] + try: + return instructions[self.mstate.pc] + except KeyError: + new_instruction = {"address": self.mstate.pc, "opcode": "STOP"} + return new_instruction @property def current_transaction(