From d9ae91c2a85dd7503dab086f8b44cd4a8e9d66fd Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Wed, 11 Dec 2024 13:36:20 -0500 Subject: [PATCH 1/2] fix: data segment names --- src/module/data.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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); From 9bb79ff182add57e8c61f8b8d133417bf52b8371 Mon Sep 17 00:00:00 2001 From: Ibiyemi Abiodun Date: Wed, 11 Dec 2024 13:46:13 -0500 Subject: [PATCH 2/2] oops --- src/module/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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