Remove unused export index check in wasm-c-api (#1720)

This commit is contained in:
liang.he 2022-11-20 18:47:02 +08:00 committed by GitHub
parent 4e5ba6f6ef
commit 3daa512925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}