yul Interpreter: Move memory size limit to interpreter state.

This commit is contained in:
Bhargava Shastry
2019-03-26 14:42:25 +01:00
parent d67a1ec1b4
commit ef94d6d645
4 changed files with 6 additions and 6 deletions
@@ -455,17 +455,13 @@ bool EVMInstructionInterpreter::logMemoryWrite(u256 const& _offset, u256 const&
bool EVMInstructionInterpreter::logMemory(bool _write, u256 const& _offset, u256 const& _size, bytes const& _data)
{
/// Memory size limit. Anything beyond this will still work, but it has
/// deterministic yet not necessarily consistent behaviour.
size_t constexpr maxMemSize = 0x20000000;
logTrace(_write ? "MSTORE_AT_SIZE" : "MLOAD_FROM_SIZE", {_offset, _size}, _data);
if (((_offset + _size) >= _offset) && ((_offset + _size + 0x1f) >= (_offset + _size)))
{
u256 newSize = (_offset + _size + 0x1f) & ~u256(0x1f);
m_state.msize = max(m_state.msize, newSize);
if (newSize < maxMemSize)
if (newSize < m_state.maxMemSize)
{
if (m_state.memory.size() < newSize)
m_state.memory.resize(size_t(newSize));