mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-07-16 09:18:29 +00:00
Fix invalid size of memory allocated in wasi init (#1603)
The total size of null-terminated array of strings is wrongly calculated
This commit is contained in:
parent
99097ce5ca
commit
02f0c2bed8
|
@ -2412,7 +2412,7 @@ copy_string_array(const char *array[], uint32 array_size, char **buf_ptr,
|
||||||
buf_size += strlen(array[i]) + 1;
|
buf_size += strlen(array[i]) + 1;
|
||||||
|
|
||||||
/* We add +1 to generate null-terminated array of strings */
|
/* We add +1 to generate null-terminated array of strings */
|
||||||
total_size = sizeof(char *) * (uint64)array_size + 1;
|
total_size = sizeof(char *) * ((uint64)array_size + 1);
|
||||||
if (total_size >= UINT32_MAX
|
if (total_size >= UINT32_MAX
|
||||||
|| (total_size > 0 && !(list = wasm_runtime_malloc((uint32)total_size)))
|
|| (total_size > 0 && !(list = wasm_runtime_malloc((uint32)total_size)))
|
||||||
|| buf_size >= UINT32_MAX
|
|| buf_size >= UINT32_MAX
|
||||||
|
|
Loading…
Reference in New Issue
Block a user