Skip to content

Commit 0090d3e

Browse files
authored
Fix issue of resolving func name in custom name section (#1849)
Should use import_function_count but not import_count to calculate the func_index in handle_name_section when custom name section feature is enabled. And clear the compile warnings of mini loader.
1 parent d1fe589 commit 0090d3e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

core/iwasm/interpreter/wasm_loader.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,8 +2806,8 @@ handle_name_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
28062806
read_leb_uint32(p, p_end, func_name_len);
28072807
CHECK_BUF(p, p_end, func_name_len);
28082808
/* Skip the import functions */
2809-
if (func_index >= module->import_count) {
2810-
func_index -= module->import_count;
2809+
if (func_index >= module->import_function_count) {
2810+
func_index -= module->import_function_count;
28112811
if (func_index >= module->function_count) {
28122812
set_error_buf(error_buf, error_buf_size,
28132813
"out-of-range function index");

core/iwasm/interpreter/wasm_mini_loader.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,8 +1708,8 @@ handle_name_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
17081708
read_leb_uint32(p, p_end, func_name_len);
17091709
CHECK_BUF(p, p_end, func_name_len);
17101710
/* Skip the import functions */
1711-
if (func_index >= module->import_count) {
1712-
func_index -= module->import_count;
1711+
if (func_index >= module->import_function_count) {
1712+
func_index -= module->import_function_count;
17131713
bh_assert(func_index < module->function_count);
17141714
if (!(module->functions[func_index]->field_name =
17151715
const_str_list_insert(
@@ -1733,6 +1733,8 @@ handle_name_section(const uint8 *buf, const uint8 *buf_end, WASMModule *module,
17331733
i++;
17341734
}
17351735

1736+
(void)previous_name_type;
1737+
(void)previous_func_index;
17361738
return true;
17371739
}
17381740
#endif

0 commit comments

Comments
 (0)