mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-29 00:21:34 +00:00
Validate descriptor max on creating new table or memory (#186)
This commit is contained in:
@ -63,6 +63,15 @@ impl Memory {
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn new(desc: MemoryDescriptor) -> Result<Self, CreationError> {
|
||||
if let Some(max) = desc.maximum {
|
||||
if max < desc.minimum {
|
||||
return Err(CreationError::InvalidDescriptor(
|
||||
"Max number of memory pages is less than the minimum number of pages"
|
||||
.to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
let variant = if !desc.shared {
|
||||
MemoryVariant::Unshared(UnsharedMemory::new(desc)?)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user