@@ -400,7 +400,8 @@ 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]->type_flag != WASM_TYPE_ARRAY) {
403
+ if (module->types[type_index] == NULL
404
+ || module->types[type_index]->type_flag != WASM_TYPE_ARRAY) {
404
405
set_error_buf(error_buf, error_buf_size, "unknown array type");
405
406
return false;
406
407
}
@@ -423,7 +424,8 @@ check_function_type(const WASMModule *module, uint32 type_index,
423
424
}
424
425
425
426
#if WASM_ENABLE_GC != 0
426
- if (module->types[type_index]->type_flag != WASM_TYPE_FUNC) {
427
+ if (module->types[type_index] == NULL
428
+ || module->types[type_index]->type_flag != WASM_TYPE_FUNC) {
427
429
set_error_buf(error_buf, error_buf_size, "unknown function type");
428
430
return false;
429
431
}
@@ -1255,8 +1257,9 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
1255
1257
error_buf_size)) {
1256
1258
goto fail;
1257
1259
}
1258
- if (module->types[type_idx]->type_flag
1259
- != WASM_TYPE_STRUCT) {
1260
+ if (module->types[type_idx] == NULL
1261
+ || module->types[type_idx]->type_flag
1262
+ != WASM_TYPE_STRUCT) {
1260
1263
set_error_buf(error_buf, error_buf_size,
1261
1264
"unknown struct type");
1262
1265
goto fail;
@@ -2303,9 +2306,14 @@ load_type_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
2303
2306
total_size = new_total_size;
2304
2307
}
2305
2308
2306
- LOG_VERBOSE("Processing rec group [%d-%d]",
2307
- processed_type_count,
2308
- processed_type_count + rec_count - 1);
2309
+ if (rec_count < 1) {
2310
+ LOG_VERBOSE("Processing 0-entry rec group");
2311
+ }
2312
+ else {
2313
+ LOG_VERBOSE("Processing rec group [%d-%d]",
2314
+ processed_type_count,
2315
+ processed_type_count + rec_count - 1);
2316
+ }
2309
2317
}
2310
2318
else {
2311
2319
p--;
@@ -12677,7 +12685,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
12677
12685
error_buf, error_buf_size)) {
12678
12686
goto fail;
12679
12687
}
12680
- if (module->types[type_idx1]->type_flag != WASM_TYPE_FUNC) {
12688
+ if (module->types[type_idx1] == NULL
12689
+ || module->types[type_idx1]->type_flag
12690
+ != WASM_TYPE_FUNC) {
12681
12691
set_error_buf(error_buf, error_buf_size,
12682
12692
"unknown function type");
12683
12693
goto fail;
@@ -12694,7 +12704,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
12694
12704
error_buf, error_buf_size)) {
12695
12705
goto fail;
12696
12706
}
12697
- if (module->types[type_idx]->type_flag != WASM_TYPE_FUNC) {
12707
+ if (module->types[type_idx] == NULL
12708
+ || module->types[type_idx]->type_flag
12709
+ != WASM_TYPE_FUNC) {
12698
12710
set_error_buf(error_buf, error_buf_size,
12699
12711
"unknown function type");
12700
12712
goto fail;
@@ -14533,8 +14545,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
14533
14545
error_buf_size)) {
14534
14546
goto fail;
14535
14547
}
14536
- if (module->types[type_idx]->type_flag
14537
- != WASM_TYPE_STRUCT) {
14548
+ if (module->types[type_idx] == NULL
14549
+ || module->types[type_idx]->type_flag
14550
+ != WASM_TYPE_STRUCT) {
14538
14551
set_error_buf(error_buf, error_buf_size,
14539
14552
"unknown struct type");
14540
14553
goto fail;
@@ -14620,8 +14633,9 @@ wasm_loader_prepare_bytecode(WASMModule *module, WASMFunction *func,
14620
14633
error_buf_size)) {
14621
14634
goto fail;
14622
14635
}
14623
- if (module->types[type_idx]->type_flag
14624
- != WASM_TYPE_STRUCT) {
14636
+ if (module->types[type_idx] == NULL
14637
+ || module->types[type_idx]->type_flag
14638
+ != WASM_TYPE_STRUCT) {
14625
14639
set_error_buf(error_buf, error_buf_size,
14626
14640
"unknown struct type");
14627
14641
goto fail;
0 commit comments