mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
evmasm/Instruction: fixes undefined behavior of advancing iterator beyond the end of a container.
Usually the STL doesn't check whether or not the developer advances beyond its container's end, but MSVC does (found out by running soltest in debug mode on Win32 / VS2017).
This commit is contained in:
parent
2c61bad3d8
commit
fb4857abed
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "./Instruction.h"
|
#include "./Instruction.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <libdevcore/Common.h>
|
#include <libdevcore/Common.h>
|
||||||
#include <libdevcore/CommonIO.h>
|
#include <libdevcore/CommonIO.h>
|
||||||
@ -325,13 +326,20 @@ void dev::solidity::eachInstruction(
|
|||||||
size_t additional = 0;
|
size_t additional = 0;
|
||||||
if (isValidInstruction(instr))
|
if (isValidInstruction(instr))
|
||||||
additional = instructionInfo(instr).additional;
|
additional = instructionInfo(instr).additional;
|
||||||
|
|
||||||
u256 data;
|
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;
|
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);
|
_onInstruction(instr, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user