Fix warnings/issues reported in Windows and by CodeQL/Coverity (#3275)

Fix the warnings and issues reported:
- in Windows platform
- by CodeQL static code analyzing
- by Coverity static code analyzing

And update CodeQL script to build exception handling and memory features.
This commit is contained in:
Wenyong Huang
2024-04-07 11:57:31 +08:00
committed by GitHub
parent 53f0941ffa
commit 2013f1f7d7
26 changed files with 202 additions and 118 deletions

View File

@ -7511,7 +7511,7 @@ at_rmw_xor_r_base_r_offset_r(x86::Assembler &a, uint32 bytes_dst,
CHECK_KIND(r3, JIT_REG_KIND_I64); \
} \
/* r0: read/return value r2: memory base addr can't be const */ \
/* already check it's not const in LOAD_4ARGS(); */ \
/* already check it's not const in LOAD_4ARGS() */ \
reg_no_dst = jit_reg_no(r0); \
CHECK_REG_NO(reg_no_dst, jit_reg_kind(r0)); \
/* mem_data base address has to be non-const */ \
@ -9419,7 +9419,7 @@ static uint8 hreg_info_F64[3][16] = {
1, 1, 1, 1, 1, 1, 1, 0 }, /* caller_saved_jitted */
};
static const JitHardRegInfo hreg_info = {
static const JitHardRegInfo g_hreg_info = {
{
{ 0, NULL, NULL, NULL }, /* VOID */
@ -9459,7 +9459,7 @@ static const JitHardRegInfo hreg_info = {
const JitHardRegInfo *
jit_codegen_get_hreg_info()
{
return &hreg_info;
return &g_hreg_info;
}
static const char *reg_names_i32[] = {

View File

@ -636,7 +636,7 @@ wasm_init_memory(WASMModuleInstance *inst, uint32 mem_idx, uint32 seg_idx,
/* if d + n > the length of mem.data */
mem_inst = inst->memories[mem_idx];
mem_size = mem_inst->cur_page_count * mem_inst->num_bytes_per_page;
mem_size = mem_inst->cur_page_count * (uint64)mem_inst->num_bytes_per_page;
if (mem_size < mem_offset || mem_size - mem_offset < len)
goto out_of_bounds;
@ -724,8 +724,10 @@ wasm_copy_memory(WASMModuleInstance *inst, uint32 src_mem_idx,
src_mem = inst->memories[src_mem_idx];
dst_mem = inst->memories[dst_mem_idx];
src_mem_size = src_mem->cur_page_count * src_mem->num_bytes_per_page;
dst_mem_size = dst_mem->cur_page_count * dst_mem->num_bytes_per_page;
src_mem_size =
src_mem->cur_page_count * (uint64)src_mem->num_bytes_per_page;
dst_mem_size =
dst_mem->cur_page_count * (uint64)dst_mem->num_bytes_per_page;
/* if s + n > the length of mem.data */
if (src_mem_size < src_offset || src_mem_size - src_offset < len)
@ -788,7 +790,7 @@ wasm_fill_memory(WASMModuleInstance *inst, uint32 mem_idx, uint32 len,
uint8 *dst_addr;
mem_inst = inst->memories[mem_idx];
mem_size = mem_inst->cur_page_count * mem_inst->num_bytes_per_page;
mem_size = mem_inst->cur_page_count * (uint64)mem_inst->num_bytes_per_page;
if (mem_size < dst || mem_size - dst < len)
goto out_of_bounds;