@@ -281,7 +281,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
281281 log:: trace!( "interning {count} Wasm types" ) ;
282282
283283 let capacity = usize:: try_from ( count) . unwrap ( ) ;
284- self . result . module . types . reserve ( capacity) ;
284+ self . result . module . types . reserve ( capacity) ? ;
285285 self . types . reserve_wasm_signatures ( capacity) ;
286286
287287 // Iterate over each *rec group* -- not type -- defined in the
@@ -318,9 +318,9 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
318318 let interned = self . types . intern_rec_group ( validator_types, rec_group_id) ?;
319319 let elems = self . types . rec_group_elements ( interned) ;
320320 let len = elems. len ( ) ;
321- self . result . module . types . reserve ( len) ;
321+ self . result . module . types . reserve ( len) ? ;
322322 for ty in elems {
323- self . result . module . types . push ( ty. into ( ) ) ;
323+ self . result . module . types . push ( ty. into ( ) ) ? ;
324324 }
325325
326326 // Advance `type_index` to the start of the next rec group.
@@ -381,7 +381,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
381381 self . validator . function_section ( & functions) ?;
382382
383383 let cnt = usize:: try_from ( functions. count ( ) ) . unwrap ( ) ;
384- self . result . module . functions . reserve_exact ( cnt) ;
384+ self . result . module . functions . reserve_exact ( cnt) ? ;
385385
386386 for entry in functions {
387387 let sigindex = entry?;
@@ -394,13 +394,13 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
394394 Payload :: TableSection ( tables) => {
395395 self . validator . table_section ( & tables) ?;
396396 let cnt = usize:: try_from ( tables. count ( ) ) . unwrap ( ) ;
397- self . result . module . tables . reserve_exact ( cnt) ;
397+ self . result . module . tables . reserve_exact ( cnt) ? ;
398398
399399 for entry in tables {
400400 let wasmparser:: Table { ty, init } = entry?;
401401 let table = self . convert_table_type ( & ty) ?;
402402 self . result . module . needs_gc_heap |= table. ref_type . is_vmgcref_type ( ) ;
403- self . result . module . tables . push ( table) ;
403+ self . result . module . tables . push ( table) ? ;
404404 let init = match init {
405405 wasmparser:: TableInit :: RefNull => TableInitialValue :: Null {
406406 precomputed : collections:: Vec :: new ( ) ,
@@ -417,19 +417,19 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
417417 . module
418418 . table_initialization
419419 . initial_values
420- . push ( init) ;
420+ . push ( init) ? ;
421421 }
422422 }
423423
424424 Payload :: MemorySection ( memories) => {
425425 self . validator . memory_section ( & memories) ?;
426426
427427 let cnt = usize:: try_from ( memories. count ( ) ) . unwrap ( ) ;
428- self . result . module . memories . reserve_exact ( cnt) ;
428+ self . result . module . memories . reserve_exact ( cnt) ? ;
429429
430430 for entry in memories {
431431 let memory = entry?;
432- self . result . module . memories . push ( memory. into ( ) ) ;
432+ self . result . module . memories . push ( memory. into ( ) ) ? ;
433433 }
434434 }
435435
@@ -451,7 +451,7 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
451451 self . validator . global_section ( & globals) ?;
452452
453453 let cnt = usize:: try_from ( globals. count ( ) ) . unwrap ( ) ;
454- self . result . module . globals . reserve_exact ( cnt) ;
454+ self . result . module . globals . reserve_exact ( cnt) ? ;
455455
456456 for entry in globals {
457457 let wasmparser:: Global { ty, init_expr } = entry?;
@@ -460,8 +460,8 @@ impl<'a, 'data> ModuleEnvironment<'a, 'data> {
460460 self . flag_func_escaped ( f) ;
461461 }
462462 let ty = self . convert_global_type ( & ty) ?;
463- self . result . module . globals . push ( ty) ;
464- self . result . module . global_initializers . push ( initializer) ;
463+ self . result . module . globals . push ( ty) ? ;
464+ self . result . module . global_initializers . push ( initializer) ? ;
465465 }
466466 }
467467
@@ -835,10 +835,18 @@ and for re-adding support for interface types you can see this issue:
835835 self . flag_func_escaped ( func_index) ;
836836 func_index
837837 } ) ,
838- EntityType :: Table ( ty) => EntityIndex :: Table ( self . result . module . tables . push ( ty) ) ,
839- EntityType :: Memory ( ty) => EntityIndex :: Memory ( self . result . module . memories . push ( ty) ) ,
840- EntityType :: Global ( ty) => EntityIndex :: Global ( self . result . module . globals . push ( ty) ) ,
841- EntityType :: Tag ( ty) => EntityIndex :: Tag ( self . result . module . tags . push ( ty) ) ,
838+ EntityType :: Table ( ty) => {
839+ EntityIndex :: Table ( self . result . module . tables . push ( ty) . panic_on_oom ( ) )
840+ }
841+ EntityType :: Memory ( ty) => {
842+ EntityIndex :: Memory ( self . result . module . memories . push ( ty) . panic_on_oom ( ) )
843+ }
844+ EntityType :: Global ( ty) => {
845+ EntityIndex :: Global ( self . result . module . globals . push ( ty) . panic_on_oom ( ) )
846+ }
847+ EntityType :: Tag ( ty) => {
848+ EntityIndex :: Tag ( self . result . module . tags . push ( ty) . panic_on_oom ( ) )
849+ }
842850 }
843851 }
844852
@@ -1099,7 +1107,7 @@ impl ModuleTranslation<'_> {
10991107 // memory initialization image is built here from the page data and then
11001108 // it's converted to a single initializer.
11011109 let data = mem:: replace ( & mut self . data , Vec :: new ( ) ) ;
1102- let mut map = PrimaryMap :: with_capacity ( info. len ( ) ) ;
1110+ let mut map = collections :: PrimaryMap :: with_capacity ( info. len ( ) ) . panic_on_oom ( ) ;
11031111 let mut module_data_size = 0u32 ;
11041112 for ( memory, info) in info. iter ( ) {
11051113 // Create the in-memory `image` which is the initialized contents of
@@ -1183,7 +1191,7 @@ impl ModuleTranslation<'_> {
11831191 } else {
11841192 None
11851193 } ;
1186- let idx = map. push ( init) ;
1194+ let idx = map. push ( init) . panic_on_oom ( ) ;
11871195 assert_eq ! ( idx, memory) ;
11881196 module_data_size += len;
11891197 }
0 commit comments