wasm: treat wrong section ID as empty section

This commit is contained in:
Brian Carroll 2022-05-26 22:02:35 +01:00
parent dad1d14ef8
commit 4a22d22515
No known key found for this signature in database
GPG Key ID: 5C7B2EC4101703C0

View File

@ -136,15 +136,10 @@ fn parse_section(
message: "End of file".into(),
});
}
// If we see the wrong section ID, assume the one we were looking for is just empty
if module_bytes[*cursor] != expected_id as u8 {
let actual_id: SectionId = unsafe { std::mem::transmute(module_bytes[*cursor]) };
return Err(ParseError {
offset: *cursor,
message: format!(
"Expected section '{:?}', but found '{:?}'",
expected_id, actual_id
),
});
return Ok((0, *cursor..*cursor));
}
*cursor += 1;