Skip to content

Commit

Permalink
fix: data segment names (#286)
Browse files Browse the repository at this point in the history
  • Loading branch information
laptou authored Dec 11, 2024
1 parent 61c6022 commit 5101fb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/module/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5101fb0

Please sign in to comment.