Skip to content

Commit 5101fb0

Browse files
authored
fix: data segment names (#286)
1 parent 61c6022 commit 5101fb0

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/module/data.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl Module {
177177
pub(crate) fn parse_data(
178178
&mut self,
179179
section: wasmparser::DataSectionReader,
180-
ids: &IndicesToIds,
180+
ids: &mut IndicesToIds,
181181
) -> Result<()> {
182182
log::debug!("parse data section");
183183
let preallocated = self.data.arena.len() > 0;
@@ -189,12 +189,16 @@ impl Module {
189189
let id = if preallocated {
190190
ids.get_data(i as u32)?
191191
} else {
192-
self.data.arena.alloc_with_id(|id| Data {
192+
let id = self.data.arena.alloc_with_id(|id| Data {
193193
id,
194194
value: Vec::new(),
195195
kind: DataKind::Passive,
196196
name: None,
197-
})
197+
});
198+
199+
ids.push_data(id);
200+
201+
id
198202
};
199203
let data = self.data.get_mut(id);
200204

src/module/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl Module {
167167
validator
168168
.data_section(&s)
169169
.context("failed to parse data section")?;
170-
ret.parse_data(s, &indices)?;
170+
ret.parse_data(s, &mut indices)?;
171171
}
172172
Payload::TypeSection(s) => {
173173
validator

0 commit comments

Comments
 (0)