@@ -249,7 +249,7 @@ impl Parser {
249249 buffer. truncate ( buffer. len ( ) - buffer_offset) ;
250250 buffer_offset = 0 ;
251251 }
252- let read_bytes = Self :: read_more ( & mut stream, & mut buffer, hint as usize ) ?;
252+ let read_bytes = Self :: read_more ( & mut stream, & mut buffer, hint) ?;
253253 eof = read_bytes == 0 ;
254254 }
255255 wasmparser:: Chunk :: Parsed { consumed, payload } => {
@@ -258,17 +258,12 @@ impl Parser {
258258
259259 match payload {
260260 wasmparser:: Payload :: CodeSectionStart { count, range, size } => {
261- let defer = reader. begin_code_section (
262- count,
263- range. clone ( ) ,
264- size,
265- validator. as_mut ( ) ,
266- & self . options ,
267- ) ?;
261+ let defer =
262+ reader. begin_code_section ( count, range, size, validator. as_mut ( ) , & self . options ) ?;
268263
269264 #[ cfg( parallel_parser) ]
270265 if defer {
271- deferred_code_section = Some ( ( count, range . end - size as usize , size as usize ) ) ;
266+ deferred_code_section = Some ( ( count, size as usize ) ) ;
272267 }
273268
274269 #[ cfg( not( parallel_parser) ) ]
@@ -284,21 +279,21 @@ impl Parser {
284279 buffer_offset += consumed;
285280
286281 #[ cfg( parallel_parser) ]
287- if let Some ( ( count, body_offset , section_size) ) = deferred_code_section {
282+ if let Some ( ( count, section_size) ) = deferred_code_section {
288283 while buffer. len ( ) - buffer_offset < section_size {
289284 let remaining = section_size - ( buffer. len ( ) - buffer_offset) ;
290285 let read_bytes = Self :: read_more ( & mut stream, & mut buffer, remaining) ?;
291286 if read_bytes == 0 {
292287 return Err ( ParseError :: ParseError {
293288 message : "unexpected end-of-file" . into ( ) ,
294- offset : body_offset + buffer. len ( ) - buffer_offset,
289+ offset : parser . offset ( ) + ( buffer. len ( ) - buffer_offset) as u64 ,
295290 } ) ;
296291 }
297292 }
298293
299294 let section_end = buffer_offset + section_size;
300295 let section_bytes = alloc:: sync:: Arc :: < [ u8 ] > :: from ( buffer[ buffer_offset..section_end] . to_vec ( ) ) ;
301- reader. queue_owned_code_section ( count, body_offset , section_bytes, validator. as_mut ( ) ) ?;
296+ reader. queue_owned_code_section ( count, parser . offset ( ) , section_bytes, validator. as_mut ( ) ) ?;
302297 parser. skip_section ( ) ;
303298 buffer_offset = section_end;
304299 continue ;
0 commit comments