diff --git a/validation/src/lib.rs b/validation/src/lib.rs index d2d0713..4815b0a 100644 --- a/validation/src/lib.rs +++ b/validation/src/lib.rs @@ -27,12 +27,10 @@ use core::fmt; #[cfg(feature = "std")] use std::error; -use alloc::collections::BTreeSet; - use self::context::ModuleContextBuilder; use parity_wasm::elements::{ - BlockType, External, FuncBody, GlobalEntry, GlobalType, InitExpr, Instruction, Internal, - MemoryType, Module, ResizableLimits, TableType, Type, ValueType, + BlockType, ExportEntry, External, FuncBody, GlobalEntry, GlobalType, InitExpr, Instruction, + Internal, MemoryType, Module, ResizableLimits, TableType, Type, ValueType, }; pub mod context; @@ -247,13 +245,21 @@ pub fn validate_module(module: &Module) -> Result>(); + + export_names.sort_unstable(); + + for (fst, snd) in export_names.iter().zip(export_names.iter().skip(1)) { + if fst == snd { + return Err(Error(format!("duplicate export {}", fst))); } + } + + for export in export_section.entries() { match *export.internal() { Internal::Function(function_index) => { context.require_function(function_index)?;