Skip to content

Commit 2f6e4b9

Browse files
committed
Merge branch main into dev/gc_refactor
2 parents bae036f + b8ff98c commit 2f6e4b9

File tree

3 files changed

+39
-11
lines changed

3 files changed

+39
-11
lines changed

core/iwasm/interpreter/wasm_loader.c

+23-8
Original file line numberDiff line numberDiff line change
@@ -6367,14 +6367,22 @@ check_wasi_abi_compatibility(const WASMModule *module,
63676367
/* clang-format on */
63686368

63696369
WASMExport *initialize = NULL, *memory = NULL, *start = NULL;
6370+
uint32 import_function_count = module->import_function_count;
6371+
WASMFuncType *func_type;
63706372

63716373
/* (func (export "_start") (...) */
63726374
start = wasm_loader_find_export(module, "", "_start", EXPORT_KIND_FUNC,
63736375
error_buf, error_buf_size);
63746376
if (start) {
6375-
WASMFuncType *func_type =
6376-
module->functions[start->index - module->import_function_count]
6377-
->func_type;
6377+
if (start->index < import_function_count) {
6378+
set_error_buf(
6379+
error_buf, error_buf_size,
6380+
"the builtin _start function can not be an import function");
6381+
return false;
6382+
}
6383+
6384+
func_type =
6385+
module->functions[start->index - import_function_count]->func_type;
63786386
if (func_type->param_count || func_type->result_count) {
63796387
set_error_buf(error_buf, error_buf_size,
63806388
"the signature of builtin _start function is wrong");
@@ -6386,11 +6394,17 @@ check_wasi_abi_compatibility(const WASMModule *module,
63866394
initialize =
63876395
wasm_loader_find_export(module, "", "_initialize", EXPORT_KIND_FUNC,
63886396
error_buf, error_buf_size);
6397+
63896398
if (initialize) {
6390-
WASMFuncType *func_type =
6391-
module
6392-
->functions[initialize->index
6393-
- module->import_function_count]
6399+
if (initialize->index < import_function_count) {
6400+
set_error_buf(error_buf, error_buf_size,
6401+
"the builtin _initialize function can not be an "
6402+
"import function");
6403+
return false;
6404+
}
6405+
6406+
func_type =
6407+
module->functions[initialize->index - import_function_count]
63946408
->func_type;
63956409
if (func_type->param_count || func_type->result_count) {
63966410
set_error_buf(
@@ -9899,7 +9913,8 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
98999913
bool is_type_multi_byte;
99009914
#endif
99019915

9902-
if (loader_ctx->csp_num < depth + 1) {
9916+
bh_assert(loader_ctx->csp_num > 0);
9917+
if (loader_ctx->csp_num - 1 < depth) {
99039918
set_error_buf(error_buf, error_buf_size,
99049919
"unknown label, "
99059920
"unexpected end of section or function");

core/iwasm/interpreter/wasm_mini_loader.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -5451,7 +5451,8 @@ wasm_loader_check_br(WASMLoaderContext *loader_ctx, uint32 depth,
54515451
int32 i, available_stack_cell;
54525452
uint16 cell_num;
54535453

5454-
if (loader_ctx->csp_num < depth + 1) {
5454+
bh_assert(loader_ctx->csp_num > 0);
5455+
if (loader_ctx->csp_num - 1 < depth) {
54555456
set_error_buf(error_buf, error_buf_size,
54565457
"unknown label, "
54575458
"unexpected end of section or function");

core/shared/platform/nuttx/nuttx_platform.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
9494

9595
#if defined(CONFIG_ARCH_USE_TEXT_HEAP)
9696
if ((prot & MMAP_PROT_EXEC) != 0) {
97-
return up_textheap_memalign(sizeof(void *), size);
97+
p = up_textheap_memalign(sizeof(void *), size);
98+
if (p) {
99+
memset(p, 0, size);
100+
}
101+
return p;
98102
}
99103
#endif
100104

@@ -108,7 +112,11 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
108112
return NULL;
109113
}
110114
i_addr = (void *)((uint8 *)d_addr + MEM_DUAL_BUS_OFFSET);
111-
return in_ibus_ext(i_addr) ? i_addr : d_addr;
115+
p = in_ibus_ext(i_addr) ? i_addr : d_addr;
116+
if (p) {
117+
memset(p, 0, size);
118+
}
119+
return p;
112120
}
113121
#endif
114122
/* Note: aot_loader.c assumes that os_mmap provides large enough
@@ -125,6 +133,10 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
125133
if (posix_memalign(&p, 32, size)) {
126134
return NULL;
127135
}
136+
137+
/* Zero the memory which is required by os_mmap */
138+
memset(p, 0, size);
139+
128140
return p;
129141
}
130142

0 commit comments

Comments
 (0)