From 3daa5129255c47738bf640bd3c97560038042d83 Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Sun, 20 Nov 2022 18:47:02 +0800 Subject: [PATCH] Remove unused export index check in wasm-c-api (#1720) --- core/iwasm/interpreter/wasm_loader.c | 31 ++-------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 4dad4fe8..c706b6c7 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -690,7 +690,6 @@ wasm_loader_find_export(const WASMModule *module, const char *module_name, { WASMExport *export; uint32 i; - uint32 export_index_boundary = 0; for (i = 0, export = module->exports; i < module->export_count; ++i, ++export) { @@ -713,34 +712,8 @@ wasm_loader_find_export(const WASMModule *module, const char *module_name, return NULL; } - switch (export_kind) { - case EXPORT_KIND_FUNC: - export_index_boundary = - module->import_function_count + module->function_count; - break; - case EXPORT_KIND_GLOBAL: - export_index_boundary = - module->import_global_count + module->global_count; - break; - case EXPORT_KIND_MEMORY: - export_index_boundary = - module->import_memory_count + module->memory_count; - break; - case EXPORT_KIND_TABLE: - export_index_boundary = - module->import_table_count + module->table_count; - break; - default: - bh_assert(0); - } - - if (export->index >= export_index_boundary) { - LOG_DEBUG("%s in the module %s is out of index (%d >= %d )", field_name, - module_name, export->index, export_index_boundary); - set_error_buf(error_buf, error_buf_size, "incompatible import type"); - return NULL; - } - + /* since there is a validation in load_export_section(), it is for sure + * export->index is valid*/ return export; }