From 8afb7b645013ba6ba97c40b18f993781acfe2c89 Mon Sep 17 00:00:00 2001 From: Sergey Pepyakin Date: Tue, 5 Dec 2017 12:12:54 +0100 Subject: [PATCH] Add checks for tables and memories count. --- src/validation/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/validation/mod.rs b/src/validation/mod.rs index 00b84c2..f5eb686 100644 --- a/src/validation/mod.rs +++ b/src/validation/mod.rs @@ -99,6 +99,17 @@ pub fn validate_module(module: &Module) -> Result { } } + + // 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,