Skip to content

Commit

Permalink
Merge pull request #576 from athei/fix-name-parsing
Browse files Browse the repository at this point in the history
Skip unknown entries in the custom name section
  • Loading branch information
AlexEne authored Aug 6, 2021
2 parents 4666310 + a04913b commit 28161c6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions parser/wasm_parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,14 @@ fn parse_names_section<'a>(
for IndexedSection(_, section) in indexed_sections.iter() {
if let wasmparser::SectionCode::Custom { name: "name", .. } = section.code {
for subsection in section.get_name_section_reader()? {
let f = match subsection? {
// We use a rather old version of wasmparser. This is a workaround
// to skip new types of name subsections instead of aborting.
let subsection = if let Ok(subsection) = subsection {
subsection
} else {
continue;
};
let f = match subsection {
wasmparser::Name::Function(f) => f,
_ => continue,
};
Expand Down Expand Up @@ -512,7 +519,13 @@ impl<'a> Parse<'a> for wasmparser::NameSectionReader<'a> {
let mut i = 0;
while !self.eof() {
let start = self.original_position();
let subsection = self.read()?;
// We use a rather old version of wasmparser. This is a workaround
// to skip new types of name subsections instead of aborting.
let subsection = if let Ok(subsection) = self.read() {
subsection
} else {
continue;
};
let size = (self.original_position() - start) as u32;
let name = match subsection {
wasmparser::Name::Module(_) => "\"module name\" subsection",
Expand Down

0 comments on commit 28161c6

Please sign in to comment.