Skip to content

Commit 7ff3cca

Browse files
committed
Add protection in load_native_symbol_section()
- #69675
1 parent 9b9e938 commit 7ff3cca

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/iwasm/aot/aot_loader.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,9 @@ load_native_symbol_section(const uint8 *buf, const uint8 *buf_end,
660660
read_uint32(p, p_end, cnt);
661661

662662
if (cnt > 0) {
663-
module->native_symbol_list = wasm_runtime_malloc(cnt * sizeof(void *));
663+
uint64 list_size = cnt * (uint64)sizeof(void *);
664+
module->native_symbol_list =
665+
loader_malloc(list_size, error_buf, error_buf_size);
664666
if (module->native_symbol_list == NULL) {
665667
set_error_buf(error_buf, error_buf_size,
666668
"malloc native symbol list failed");
@@ -669,6 +671,9 @@ load_native_symbol_section(const uint8 *buf, const uint8 *buf_end,
669671

670672
for (i = cnt - 1; i >= 0; i--) {
671673
read_string(p, p_end, symbol);
674+
if (!strlen(symbol))
675+
continue;
676+
672677
if (!strncmp(symbol, "f32#", 4) || !strncmp(symbol, "i32#", 4)) {
673678
uint32 u32;
674679
/* Resolve the raw int bits of f32 const */
@@ -698,7 +703,7 @@ load_native_symbol_section(const uint8 *buf, const uint8 *buf_end,
698703
else {
699704
module->native_symbol_list[i] =
700705
get_native_symbol_by_name(symbol);
701-
if (module->native_symbol_list[i] == NULL) {
706+
if (!module->native_symbol_list[i]) {
702707
set_error_buf_v(error_buf, error_buf_size,
703708
"missing native symbol: %s", symbol);
704709
goto fail;

0 commit comments

Comments
 (0)