From d0e2a7271c877ac3f6955500386bf49c1ee326ee Mon Sep 17 00:00:00 2001 From: "liang.he" Date: Fri, 21 Feb 2025 07:46:20 +0800 Subject: [PATCH] fix(aot_emit_aot_file): prevent buffer emission for zero byte_count (#4095) if using a debug building of wamrc to run spec test. there will be: core/iwasm/compilation/aot_emit_aot_file.c:1794:13: runtime error: null pointer passed as argument 2, which is declared to never be null --- core/iwasm/compilation/aot_emit_aot_file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/iwasm/compilation/aot_emit_aot_file.c b/core/iwasm/compilation/aot_emit_aot_file.c index 9b2436a2b..cfb27fdeb 100644 --- a/core/iwasm/compilation/aot_emit_aot_file.c +++ b/core/iwasm/compilation/aot_emit_aot_file.c @@ -1790,7 +1790,9 @@ aot_emit_mem_info(uint8 *buf, uint8 *buf_end, uint32 *p_offset, &init_datas[i]->offset)) return false; EMIT_U32(init_datas[i]->byte_count); - EMIT_BUF(init_datas[i]->bytes, init_datas[i]->byte_count); + if (init_datas[i]->byte_count) { + EMIT_BUF(init_datas[i]->bytes, init_datas[i]->byte_count); + } } if (offset - *p_offset != get_mem_info_size(comp_ctx, comp_data)) {