Add checks for tables and memories count.

This commit is contained in:
Sergey Pepyakin 2017-12-05 12:12:54 +01:00
parent 991fb8fcd8
commit 8afb7b6450

View File

@ -99,6 +99,17 @@ pub fn validate_module(module: &Module) -> Result<ValidatedModule, Error> {
}
}
// there must be no greater than 1 table in tables index space
if context.tables().len() > 1 {
return Err(Error(format!("too many tables in index space: {}", context.tables().len())));
}
// there must be no greater than 1 linear memory in memory index space
if context.memories().len() > 1 {
return Err(Error(format!("too many memory regions in index space: {}", context.memories().len())));
}
let ModuleContext {
types,
tables,