Просмотр исходного кода

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

liang.he 3 лет назад
Родитель
Сommit
3daa512925
1 измененных файлов с 2 добавлено и 29 удалено
  1. 2 29
      core/iwasm/interpreter/wasm_loader.c

+ 2 - 29
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;
 }