From 7bac8db16a654c4368163b6b6173f3ff47f6d615 Mon Sep 17 00:00:00 2001 From: wenlingyun1 Date: Wed, 9 Oct 2024 19:06:13 +0800 Subject: [PATCH] fix bug of function "destroy_shared_heaps" Signed-off-by: wenlingyun1 --- core/iwasm/common/wasm_memory.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index d2d89e5952..3c3a2e4052 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -177,6 +177,8 @@ wasm_runtime_create_shared_heap(SharedHeapInitArgs *init_args) goto fail1; } + memset(heap, 0, heap_struct_size); + if (!(heap->heap_handle = runtime_malloc(mem_allocator_get_heap_struct_size()))) { goto fail2; @@ -534,10 +536,15 @@ wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type, static void destroy_shared_heaps() { - WASMSharedHeap *heap = shared_heap_list; + WASMSharedHeap *heap; WASMSharedHeap *cur; uint64 map_size; + os_mutex_lock(&shared_heap_list_lock); + heap = shared_heap_list; + shared_heap_list = NULL; + os_mutex_unlock(&shared_heap_list_lock); + while (heap) { cur = heap; heap = heap->next;