Skip to content

Commit d0e2a72

Browse files
authored
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
1 parent ff10b86 commit d0e2a72

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/iwasm/compilation/aot_emit_aot_file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,9 @@ aot_emit_mem_info(uint8 *buf, uint8 *buf_end, uint32 *p_offset,
17901790
&init_datas[i]->offset))
17911791
return false;
17921792
EMIT_U32(init_datas[i]->byte_count);
1793-
EMIT_BUF(init_datas[i]->bytes, init_datas[i]->byte_count);
1793+
if (init_datas[i]->byte_count) {
1794+
EMIT_BUF(init_datas[i]->bytes, init_datas[i]->byte_count);
1795+
}
17941796
}
17951797

17961798
if (offset - *p_offset != get_mem_info_size(comp_ctx, comp_data)) {

0 commit comments

Comments
 (0)