From 87588caa7f204fd0d9fce80f76c318f58817b585 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Mon, 21 Oct 2024 09:57:42 +0800 Subject: [PATCH] Fix lookup function issue reported in nightly run (#3868) --- core/iwasm/aot/aot_runtime.c | 3 +++ core/iwasm/interpreter/wasm_runtime.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/core/iwasm/aot/aot_runtime.c b/core/iwasm/aot/aot_runtime.c index 81e6aa1e..7e6d6360 100644 --- a/core/iwasm/aot/aot_runtime.c +++ b/core/iwasm/aot/aot_runtime.c @@ -2222,6 +2222,9 @@ aot_lookup_function(const AOTModuleInstance *module_inst, const char *name) (AOTFunctionInstance *)module_inst->export_functions; AOTFunctionInstance key = { .func_name = (char *)name }; + if (!export_funcs) + return NULL; + return bsearch(&key, export_funcs, module_inst->export_func_count, sizeof(AOTFunctionInstance), cmp_func_inst); } diff --git a/core/iwasm/interpreter/wasm_runtime.c b/core/iwasm/interpreter/wasm_runtime.c index 78900cb8..accb4031 100644 --- a/core/iwasm/interpreter/wasm_runtime.c +++ b/core/iwasm/interpreter/wasm_runtime.c @@ -3437,6 +3437,9 @@ wasm_lookup_function(const WASMModuleInstance *module_inst, const char *name) WASMExportFuncInstance key = { .name = (char *)name }; WASMExportFuncInstance *export_func_inst; + if (!module_inst->export_functions) + return NULL; + export_func_inst = bsearch( &key, module_inst->export_functions, module_inst->export_func_count, sizeof(WASMExportFuncInstance), cmp_export_func_inst);