Skip to content

Commit 7bbdbf5

Browse files
authored
add validation for array type in load_init_expr(GC only) (#4370)
1 parent d7e3e37 commit 7bbdbf5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/iwasm/aot/aot_loader.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,13 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module,
13091309
read_uint32(buf, buf_end, type_idx);
13101310
read_uint32(buf, buf_end, length);
13111311

1312+
if (type_idx >= module->type_count
1313+
|| !wasm_type_is_array_type(module->types[type_idx])) {
1314+
set_error_buf(error_buf, error_buf_size,
1315+
"invalid or non-array type index.");
1316+
goto fail;
1317+
}
1318+
13121319
if (init_expr_type == INIT_EXPR_TYPE_ARRAY_NEW_DEFAULT) {
13131320
expr->u.array_new_default.type_index = type_idx;
13141321
expr->u.array_new_default.length = length;

0 commit comments

Comments
 (0)