Add checks to avoid wasm_runtime_malloc memory with size 0 (#507)
In some platforms, allocating memory with size 0 may return NULL but not an empty memory block, which causes runtime load, instantiate or execute wasm/aot file failed. We add checks to try to avoid allocating memory in runtime if the size is 0. And in wasm_runtime_malloc/free, output warning if allocate memory with size 0 and free memory with NULL ptr. Also fix some coding style issues, fix handle riscv32 ilp32d issue, and fix several wasm-c-api issues. Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
@ -1652,7 +1652,8 @@ static __wasi_errno_t path_get_nofollow(
|
||||
static void path_put(
|
||||
struct path_access *pa
|
||||
) UNLOCKS(pa->fd_object->refcount) {
|
||||
wasm_runtime_free(pa->path_start);
|
||||
if (pa->path_start)
|
||||
wasm_runtime_free(pa->path_start);
|
||||
if (fd_number(pa->fd_object) != pa->fd)
|
||||
close(pa->fd);
|
||||
fd_object_release(pa->fd_object);
|
||||
|
||||
Reference in New Issue
Block a user