From 02f0c2bed8117f7da4f058bf4eaa9c22d3545be5 Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Mon, 17 Oct 2022 08:48:07 +0800 Subject: [PATCH] Fix invalid size of memory allocated in wasi init (#1603) The total size of null-terminated array of strings is wrongly calculated --- core/iwasm/common/wasm_runtime_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index c528e7f05..409ea0ffe 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -2412,7 +2412,7 @@ copy_string_array(const char *array[], uint32 array_size, char **buf_ptr, buf_size += strlen(array[i]) + 1; /* 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 || (total_size > 0 && !(list = wasm_runtime_malloc((uint32)total_size))) || buf_size >= UINT32_MAX