@@ -400,8 +400,7 @@ check_array_type(const WASMModule *module, uint32 type_index, char *error_buf,
400
400
error_buf_size)) {
401
401
return false;
402
402
}
403
- if (module->types[type_index] == NULL
404
- || module->types[type_index]->type_flag != WASM_TYPE_ARRAY) {
403
+ if (module->types[type_index]->type_flag != WASM_TYPE_ARRAY) {
405
404
set_error_buf(error_buf, error_buf_size, "unknown array type");
406
405
return false;
407
406
}
@@ -424,8 +423,7 @@ check_function_type(const WASMModule *module, uint32 type_index,
424
423
}
425
424
426
425
#if WASM_ENABLE_GC != 0
427
- if (module->types[type_index] == NULL
428
- || module->types[type_index]->type_flag != WASM_TYPE_FUNC) {
426
+ if (module->types[type_index]->type_flag != WASM_TYPE_FUNC) {
429
427
set_error_buf(error_buf, error_buf_size, "unknown function type");
430
428
return false;
431
429
}
@@ -1257,9 +1255,8 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
1257
1255
error_buf_size)) {
1258
1256
goto fail;
1259
1257
}
1260
- if (module->types[type_idx] == NULL
1261
- || module->types[type_idx]->type_flag
1262
- != WASM_TYPE_STRUCT) {
1258
+ if (module->types[type_idx]->type_flag
1259
+ != WASM_TYPE_STRUCT) {
1263
1260
set_error_buf(error_buf, error_buf_size,
1264
1261
"unknown struct type");
1265
1262
goto fail;
@@ -2499,6 +2496,13 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
2499
2496
#endif /* end of WASM_ENABLE_GC == 0 */
2500
2497
}
2501
2498
2499
+ for (i = 0; i < module->type_count; i++) {
2500
+ if (module->types[i] == NULL) {
2501
+ set_error_buf_v(error_buf, error_buf_size, "unknown type %d", i);
2502
+ return false;
2503
+ }
2504
+ }
2505
+
2502
2506
if (p != p_end) {
2503
2507
set_error_buf(error_buf, error_buf_size, "section size mismatch");
2504
2508
return false;
@@ -12685,9 +12689,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
12685
12689
error_buf, error_buf_size)) {
12686
12690
goto fail;
12687
12691
}
12688
- if (module->types[type_idx1] == NULL
12689
- || module->types[type_idx1]->type_flag
12690
- != WASM_TYPE_FUNC) {
12692
+ if (module->types[type_idx1]->type_flag != WASM_TYPE_FUNC) {
12691
12693
set_error_buf(error_buf, error_buf_size,
12692
12694
"unknown function type");
12693
12695
goto fail;
@@ -12704,9 +12706,7 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
12704
12706
error_buf, error_buf_size)) {
12705
12707
goto fail;
12706
12708
}
12707
- if (module->types[type_idx] == NULL
12708
- || module->types[type_idx]->type_flag
12709
- != WASM_TYPE_FUNC) {
12709
+ if (module->types[type_idx]->type_flag != WASM_TYPE_FUNC) {
12710
12710
set_error_buf(error_buf, error_buf_size,
12711
12711
"unknown function type");
12712
12712
goto fail;
@@ -14542,9 +14542,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
14542
14542
error_buf_size)) {
14543
14543
goto fail;
14544
14544
}
14545
- if (module->types[type_idx] == NULL
14546
- || module->types[type_idx]->type_flag
14547
- != WASM_TYPE_STRUCT) {
14545
+ if (module->types[type_idx]->type_flag
14546
+ != WASM_TYPE_STRUCT) {
14548
14547
set_error_buf(error_buf, error_buf_size,
14549
14548
"unknown struct type");
14550
14549
goto fail;
@@ -14630,9 +14629,8 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
14630
14629
error_buf_size)) {
14631
14630
goto fail;
14632
14631
}
14633
- if (module->types[type_idx] == NULL
14634
- || module->types[type_idx]->type_flag
14635
- != WASM_TYPE_STRUCT) {
14632
+ if (module->types[type_idx]->type_flag
14633
+ != WASM_TYPE_STRUCT) {
14636
14634
set_error_buf(error_buf, error_buf_size,
14637
14635
"unknown struct type");
14638
14636
goto fail;
0 commit comments