Skip to content

Commit 02f0c2b

Browse files
authored
Fix invalid size of memory allocated in wasi init (#1603)
The total size of null-terminated array of strings is wrongly calculated
1 parent 99097ce commit 02f0c2b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/iwasm/common/wasm_runtime_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,7 @@ copy_string_array(const char *array[], uint32 array_size, char **buf_ptr,
24122412
buf_size += strlen(array[i]) + 1;
24132413

24142414
/* We add +1 to generate null-terminated array of strings */
2415-
total_size = sizeof(char *) * (uint64)array_size + 1;
2415+
total_size = sizeof(char *) * ((uint64)array_size + 1);
24162416
if (total_size >= UINT32_MAX
24172417
|| (total_size > 0 && !(list = wasm_runtime_malloc((uint32)total_size)))
24182418
|| buf_size >= UINT32_MAX

0 commit comments

Comments
 (0)