diff --git a/src/module/data.rs b/src/module/data.rs index f6442c8c..df0c3e00 100644 --- a/src/module/data.rs +++ b/src/module/data.rs @@ -177,7 +177,7 @@ impl Module { pub(crate) fn parse_data( &mut self, section: wasmparser::DataSectionReader, - ids: &IndicesToIds, + ids: &mut IndicesToIds, ) -> Result<()> { log::debug!("parse data section"); let preallocated = self.data.arena.len() > 0; @@ -189,12 +189,16 @@ impl Module { let id = if preallocated { ids.get_data(i as u32)? } else { - self.data.arena.alloc_with_id(|id| Data { + let id = self.data.arena.alloc_with_id(|id| Data { id, value: Vec::new(), kind: DataKind::Passive, name: None, - }) + }); + + ids.push_data(id); + + id }; let data = self.data.get_mut(id); diff --git a/src/module/mod.rs b/src/module/mod.rs index 6069b1e5..a810a5a7 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -167,7 +167,7 @@ impl Module { validator .data_section(&s) .context("failed to parse data section")?; - ret.parse_data(s, &indices)?; + ret.parse_data(s, &mut indices)?; } Payload::TypeSection(s) => { validator