diff --git a/system-contracts/contracts/EvmInterpreterLoop.template.yul b/system-contracts/contracts/EvmInterpreterLoop.template.yul index b2925c281..9fe08f42d 100644 --- a/system-contracts/contracts/EvmInterpreterLoop.template.yul +++ b/system-contracts/contracts/EvmInterpreterLoop.template.yul @@ -411,7 +411,8 @@ for { } true { } { size, sp := popStackItemWithoutCheck(sp) checkOverflow(destOffset, size, evmGasLeft) - checkMultipleOverflow(offset, size, MEM_OFFSET_INNER(), evmGasLeft) + checkOverflow(offset, size, evmGasLeft) + checkOverflow(add(offset, size), MEM_OFFSET_INNER(), evmGasLeft) checkMemOverflowByOffset(add(destOffset,size), evmGasLeft) if gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_MEMORY_FRAME()) { diff --git a/system-contracts/contracts/EvmInterpreterPreprocessed.yul b/system-contracts/contracts/EvmInterpreterPreprocessed.yul index 28794aadc..c1ce65a83 100644 --- a/system-contracts/contracts/EvmInterpreterPreprocessed.yul +++ b/system-contracts/contracts/EvmInterpreterPreprocessed.yul @@ -1942,7 +1942,8 @@ object "EVMInterpreter" { size, sp := popStackItemWithoutCheck(sp) checkOverflow(destOffset, size, evmGasLeft) - checkMultipleOverflow(offset, size, MEM_OFFSET_INNER(), evmGasLeft) + checkOverflow(offset, size, evmGasLeft) + checkOverflow(add(offset, size), MEM_OFFSET_INNER(), evmGasLeft) checkMemOverflowByOffset(add(destOffset,size), evmGasLeft) if gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_MEMORY_FRAME()) { @@ -4905,7 +4906,8 @@ object "EVMInterpreter" { size, sp := popStackItemWithoutCheck(sp) checkOverflow(destOffset, size, evmGasLeft) - checkMultipleOverflow(offset, size, MEM_OFFSET_INNER(), evmGasLeft) + checkOverflow(offset, size, evmGasLeft) + checkOverflow(add(offset, size), MEM_OFFSET_INNER(), evmGasLeft) checkMemOverflowByOffset(add(destOffset,size), evmGasLeft) if gt(add(add(offset, size), MEM_OFFSET_INNER()), MAX_MEMORY_FRAME()) {