File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -697,7 +697,9 @@ impl<'a> BinaryReader<'a> {
697
697
}
698
698
699
699
/// Reads a WebAssembly string from the module.
700
+ ///
700
701
/// # Errors
702
+ ///
701
703
/// If `BinaryReader` has less than up to four bytes remaining, the string's
702
704
/// length exceeds the remaining bytes, the string's length exceeds
703
705
/// `limits::MAX_WASM_STRING_SIZE`, or the string contains invalid utf-8.
@@ -713,6 +715,10 @@ impl<'a> BinaryReader<'a> {
713
715
}
714
716
715
717
/// Reads a unlimited WebAssembly string from the module.
718
+ ///
719
+ /// Note that this is similar to [`BinaryReader::read_string`] except that
720
+ /// it will not limit the size of the returned string by
721
+ /// `limits::MAX_WASM_STRING_SIZE`.
716
722
pub fn read_unlimited_string ( & mut self ) -> Result < & ' a str > {
717
723
let len = self . read_var_u32 ( ) ? as usize ;
718
724
return self . internal_read_string ( len) ;
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ pub struct Naming<'a> {
33
33
impl < ' a > FromReader < ' a > for Naming < ' a > {
34
34
fn from_reader ( reader : & mut BinaryReader < ' a > ) -> Result < Self > {
35
35
let index = reader. read_var_u32 ( ) ?;
36
+ // This seems to match what browsers do where they don't limit the
37
+ // length of names in the `name` section while they do limit the names
38
+ // in the import and export section for example.
36
39
let name = reader. read_unlimited_string ( ) ?;
37
40
Ok ( Naming { index, name } )
38
41
}
You can’t perform that action at this time.
0 commit comments