diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index f9bbad2cf..37c5fdd40 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -21,6 +21,7 @@ #include "./Instruction.h" +#include #include #include #include @@ -325,13 +326,20 @@ void dev::solidity::eachInstruction( size_t additional = 0; if (isValidInstruction(instr)) additional = instructionInfo(instr).additional; + u256 data; - for (size_t i = 0; i < additional; ++i) + + // fill the data with the additional data bytes from the instruction stream + while (additional > 0 && next(it) < _mem.end()) { data <<= 8; - if (++it < _mem.end()) - data |= *it; + data |= *++it; + --additional; } + + // pad the remaining number of additional octets with zeros + data <<= 8 * additional; + _onInstruction(instr, data); } }