diff --git a/core/iwasm/common/wasm_memory.c b/core/iwasm/common/wasm_memory.c index 02ab1b764d..21152b37f9 100644 --- a/core/iwasm/common/wasm_memory.c +++ b/core/iwasm/common/wasm_memory.c @@ -796,10 +796,9 @@ wasm_runtime_shared_heap_malloc(WASMModuleInstanceCommon *module_inst, *p_native_addr = native_addr; } - return memory->is_memory64 - ? shared_heap->start_off_mem64 - : shared_heap->start_off_mem32 - + ((uint8 *)native_addr - shared_heap->base_addr); + return (memory->is_memory64 ? shared_heap->start_off_mem64 + : shared_heap->start_off_mem32) + + (uintptr_t)((uint8 *)native_addr - shared_heap->base_addr); } void diff --git a/core/shared/platform/zephyr/zephyr_file.c b/core/shared/platform/zephyr/zephyr_file.c index 1f48bc010c..2cb1aa5456 100644 --- a/core/shared/platform/zephyr/zephyr_file.c +++ b/core/shared/platform/zephyr/zephyr_file.c @@ -451,6 +451,7 @@ os_openat(os_file_handle handle, const char *path, __wasi_oflags_t oflags, } if (!build_absolute_path(abs_path, sizeof(abs_path), path)) { + BH_FREE(*out); return __WASI_ENOMEM; } diff --git a/core/shared/utils/bh_queue.c b/core/shared/utils/bh_queue.c index ddbb6fffe2..4fc756fbe4 100644 --- a/core/shared/utils/bh_queue.c +++ b/core/shared/utils/bh_queue.c @@ -96,14 +96,15 @@ bh_queue_destroy(bh_queue *queue) bool bh_post_msg2(bh_queue *queue, bh_queue_node *msg) { + bh_queue_mutex_lock(&queue->queue_lock); + if (queue->cnt >= queue->max) { queue->drops++; bh_free_msg(msg); + bh_queue_mutex_unlock(&queue->queue_lock); return false; } - bh_queue_mutex_lock(&queue->queue_lock); - if (queue->cnt == 0) { bh_assert(queue->head == NULL); bh_assert(queue->tail == NULL); @@ -131,7 +132,9 @@ bh_post_msg(bh_queue *queue, unsigned short tag, void *body, unsigned int len) { bh_queue_node *msg = bh_new_msg(tag, body, len, NULL); if (msg == NULL) { + bh_queue_mutex_lock(&queue->queue_lock); queue->drops++; + bh_queue_mutex_unlock(&queue->queue_lock); if (len != 0 && body) BH_FREE(body); return false;