mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-12 22:41:40 +00:00
added memory/table import limits validation
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use std::u32;
|
||||
use std::sync::Arc;
|
||||
use parking_lot::RwLock;
|
||||
use elements::TableType;
|
||||
use elements::{TableType, ResizableLimits};
|
||||
use interpreter::{Error, UserError};
|
||||
use interpreter::module::check_limits;
|
||||
use interpreter::variable::{VariableInstance, VariableType};
|
||||
@ -9,6 +9,8 @@ use interpreter::value::RuntimeValue;
|
||||
|
||||
/// Table instance.
|
||||
pub struct TableInstance<E: UserError> {
|
||||
/// Table limits.
|
||||
limits: ResizableLimits,
|
||||
/// Table variables type.
|
||||
variable_type: VariableType,
|
||||
/// Table memory buffer.
|
||||
@ -27,6 +29,7 @@ impl<E> TableInstance<E> where E: UserError {
|
||||
|
||||
let variable_type = table_type.elem_type().into();
|
||||
Ok(Arc::new(TableInstance {
|
||||
limits: table_type.limits().clone(),
|
||||
variable_type: variable_type,
|
||||
buffer: RwLock::new(
|
||||
vec![TableElement::new(VariableInstance::new(true, variable_type, RuntimeValue::Null)?); table_type.limits().initial() as usize]
|
||||
@ -34,6 +37,11 @@ impl<E> TableInstance<E> where E: UserError {
|
||||
}))
|
||||
}
|
||||
|
||||
/// Return table limits.
|
||||
pub fn limits(&self) -> &ResizableLimits {
|
||||
&self.limits
|
||||
}
|
||||
|
||||
/// Get variable type for this table.
|
||||
pub fn variable_type(&self) -> VariableType {
|
||||
self.variable_type
|
||||
|
Reference in New Issue
Block a user