Skip to content

Commit 28161c6

Browse files
authored
Merge pull request #576 from athei/fix-name-parsing
Skip unknown entries in the custom name section
2 parents 4666310 + a04913b commit 28161c6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

parser/wasm_parse/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,14 @@ fn parse_names_section<'a>(
323323
for IndexedSection(_, section) in indexed_sections.iter() {
324324
if let wasmparser::SectionCode::Custom { name: "name", .. } = section.code {
325325
for subsection in section.get_name_section_reader()? {
326-
let f = match subsection? {
326+
// We use a rather old version of wasmparser. This is a workaround
327+
// to skip new types of name subsections instead of aborting.
328+
let subsection = if let Ok(subsection) = subsection {
329+
subsection
330+
} else {
331+
continue;
332+
};
333+
let f = match subsection {
327334
wasmparser::Name::Function(f) => f,
328335
_ => continue,
329336
};
@@ -512,7 +519,13 @@ impl<'a> Parse<'a> for wasmparser::NameSectionReader<'a> {
512519
let mut i = 0;
513520
while !self.eof() {
514521
let start = self.original_position();
515-
let subsection = self.read()?;
522+
// We use a rather old version of wasmparser. This is a workaround
523+
// to skip new types of name subsections instead of aborting.
524+
let subsection = if let Ok(subsection) = self.read() {
525+
subsection
526+
} else {
527+
continue;
528+
};
516529
let size = (self.original_position() - start) as u32;
517530
let name = match subsection {
518531
wasmparser::Name::Module(_) => "\"module name\" subsection",

0 commit comments

Comments
 (0)