mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-13 06:51:45 +00:00
next potion of tests added
This commit is contained in:
@ -7,6 +7,8 @@ use interpreter::module::check_limits;
|
||||
|
||||
/// Linear memory page size.
|
||||
pub const LINEAR_MEMORY_PAGE_SIZE: u32 = 65536;
|
||||
/// Maximal number of pages.
|
||||
const LINEAR_MEMORY_MAX_PAGES: u32 = 65536;
|
||||
|
||||
/// Linear memory instance.
|
||||
pub struct MemoryInstance {
|
||||
@ -21,6 +23,12 @@ impl MemoryInstance {
|
||||
pub fn new(memory_type: &MemoryType) -> Result<Arc<Self>, Error> {
|
||||
check_limits(memory_type.limits())?;
|
||||
|
||||
if let Some(maximum_pages) = memory_type.limits().maximum() {
|
||||
if maximum_pages > LINEAR_MEMORY_MAX_PAGES {
|
||||
return Err(Error::Memory(format!("memory size must be at most 65536 pages")));
|
||||
}
|
||||
}
|
||||
|
||||
let memory = MemoryInstance {
|
||||
buffer: RwLock::new(Vec::new()), // TODO: with_capacity
|
||||
maximum_size: memory_type.limits().maximum()
|
||||
@ -64,7 +72,7 @@ impl MemoryInstance {
|
||||
};
|
||||
|
||||
let mut buffer = self.buffer.write();
|
||||
if buffer.len() <= end {
|
||||
if buffer.len() < end {
|
||||
return Err(Error::Memory(format!("trying to update region [{}..{}] in memory [0..{}]", begin, end, buffer.len())));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user