Skip to content

Commit

Permalink
fix(levm): correctly return outOfBounds in RETURNDATACOPY (#1515)
Browse files Browse the repository at this point in the history
**Motivation**

Fix the remaining tests from the folder `stMemoryTest`

**Description**
- The opcode `RETURNDATACOPY` should fail if trying to read outside of
the size of returndatabounds even if size is 0. Added a check for this
case.

**Resources**
- Comment in line 238 and 238 from [this
test](https://github.com/ethereum/tests/blob/develop/src/GeneralStateTestsFiller/stMemoryTest/bufferSrcOffsetFiller.yml#L238-L239)
  • Loading branch information
LeanSerra authored Dec 16, 2024
1 parent 378d9b5 commit 212ed58
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/vm/levm/src/opcode_handlers/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl VM {
gas_cost::returndatacopy(new_memory_size, current_call_frame.memory.len(), size)?,
)?;

if size == 0 {
if size == 0 && returndata_offset == 0 {
return Ok(OpcodeSuccess::Continue);
}

Expand Down

0 comments on commit 212ed58

Please sign in to comment.