Fix potential integer overflow issue in wasm-c-api (#1954)

Fix potential integer overflow issue in wasm-c-api reported by CodeQL
This commit is contained in:
ocfox 2023-02-13 13:55:50 +08:00 committed by GitHub
parent 89c11c5361
commit 427abf02c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4205,7 +4205,8 @@ wasm_memory_data_size(const wasm_memory_t *memory)
(WASMModuleInstance *)module_inst_comm;
WASMMemoryInstance *memory_inst =
module_inst->memories[memory->memory_idx_rt];
return memory_inst->cur_page_count * memory_inst->num_bytes_per_page;
return (size_t)memory_inst->cur_page_count
* memory_inst->num_bytes_per_page;
}
#endif
@ -4215,7 +4216,8 @@ wasm_memory_data_size(const wasm_memory_t *memory)
AOTMemoryInstance *memory_inst =
((AOTMemoryInstance **)
module_inst->memories)[memory->memory_idx_rt];
return memory_inst->cur_page_count * memory_inst->num_bytes_per_page;
return (size_t)memory_inst->cur_page_count
* memory_inst->num_bytes_per_page;
}
#endif