Removed uint8view() from the memory API and redundant FunctionEnv in tests

This commit is contained in:
John Sharratt's Shared Account
2022-08-02 10:50:34 +10:00
parent 6074045514
commit 8ff164036d
18 changed files with 88 additions and 39 deletions

View File

@@ -8,6 +8,7 @@ use std::marker::PhantomData;
use std::mem;
use std::mem::MaybeUninit;
use std::slice;
#[cfg(feature = "tracing")]
use tracing::warn;
use wasmer_types::Pages;
use wasmer_vm::{InternalStoreHandle, MemoryError, StoreHandle, StoreObjects, VMExtern, VMMemory};
@@ -177,6 +178,7 @@ impl<'a> MemoryBuffer<'a> {
.checked_add(buf.len() as u64)
.ok_or(MemoryAccessError::Overflow)?;
if end > self.len.try_into().unwrap() {
#[cfg(feature = "tracing")]
warn!("attempted to read ({} bytes) beyond the bounds of the memory view ({} > {})", buf.len(), end, self.len);
return Err(MemoryAccessError::HeapOutOfBounds);
}
@@ -195,6 +197,7 @@ impl<'a> MemoryBuffer<'a> {
.checked_add(buf.len() as u64)
.ok_or(MemoryAccessError::Overflow)?;
if end > self.len.try_into().unwrap() {
#[cfg(feature = "tracing")]
warn!("attempted to read ({} bytes) beyond the bounds of the memory view ({} > {})", buf.len(), end, self.len);
return Err(MemoryAccessError::HeapOutOfBounds);
}
@@ -211,6 +214,7 @@ impl<'a> MemoryBuffer<'a> {
.checked_add(data.len() as u64)
.ok_or(MemoryAccessError::Overflow)?;
if end > self.len.try_into().unwrap() {
#[cfg(feature = "tracing")]
warn!("attempted to write ({} bytes) beyond the bounds of the memory view ({} > {})", data.len(), end, self.len);
return Err(MemoryAccessError::HeapOutOfBounds);
}