From 378320b886e160b99757e558761c75ab085ebf47 Mon Sep 17 00:00:00 2001 From: Zhenwei Jin <109658203+kylo5aby@users.noreply.github.com> Date: Fri, 1 Aug 2025 08:58:26 +0800 Subject: [PATCH] loader: add type index checking (#4521) --- core/iwasm/aot/aot_loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index d53f7c52d..b0f155665 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -1786,7 +1786,8 @@ load_types(const uint8 **p_buf, const uint8 *buf_end, AOTModule *module, read_uint32(buf, buf_end, j); #if WASM_ENABLE_AOT_VALIDATOR != 0 - if (j >= module->type_count) { + /* an equivalence type should be before the type it refers to */ + if (j > i) { set_error_buf(error_buf, error_buf_size, "invalid type index"); goto fail; }