add support to ignore empty memory section when packing

This commit is contained in:
2022-11-03 23:27:53 +01:00
parent 142b6a4c15
commit 8d5374a867

View File

@@ -220,6 +220,11 @@ impl<'a> ParsedModule<'a> {
validate_table_section(reader)?; validate_table_section(reader)?;
table_section = Some(Section::new(range, ())); table_section = Some(Section::new(range, ()));
} }
Payload::MemorySection(reader) => {
if reader.get_count() != 0 {
bail!("Found non-empty MemorySection. Memory has to be imported!");
}
}
Payload::ElementSection(mut reader) => { Payload::ElementSection(mut reader) => {
let mut elements = Vec::with_capacity(reader.get_count() as usize); let mut elements = Vec::with_capacity(reader.get_count() as usize);
for _ in 0..reader.get_count() { for _ in 0..reader.get_count() {