Skip to content

Commit

Permalink
fix(levm): logx non-compliance memory allocation (#1330)
Browse files Browse the repository at this point in the history
Resolves #1323
  • Loading branch information
ilitteri authored Nov 28, 2024
1 parent 37daa66 commit 57e7311
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/vm/levm/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ impl Memory {
}

pub fn load_range(&mut self, offset: usize, size: usize) -> Result<Vec<u8>, VMError> {
if size == 0 {
return Ok(Vec::new());
}

let size_to_load = offset.checked_add(size).ok_or(VMError::Internal(
InternalError::ArithmeticOperationOverflow,
))?;
Expand Down
11 changes: 11 additions & 0 deletions crates/vm/levm/tests/edge_case_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,14 @@ fn test_non_compliance_extcodecopy_size_and_destoffset() {
&U256::from(64)
);
}

#[test]
fn test_non_compliance_log() {
let mut vm = new_vm_with_bytecode(Bytes::copy_from_slice(&[95, 97, 89, 0, 160, 89])).unwrap();
let mut current_call_frame = vm.call_frames.pop().unwrap();
vm.execute(&mut current_call_frame);
assert_eq!(
current_call_frame.stack.stack.first().unwrap(),
&U256::zero()
);
}

0 comments on commit 57e7311

Please sign in to comment.