Преглед изворни кода

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
liang.he пре 10 месеци
родитељ
комит
d0e2a7271c
1 измењених фајлова са 3 додато и 1 уклоњено
  1. 3 1
      core/iwasm/compilation/aot_emit_aot_file.c

+ 3 - 1
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)) {