Fix some issues reported by CodeQL (#3064)
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/pull/2812 and https://github.com/bytecodealliance/wasm-micro-runtime/security/code-scanning?query=pr%3A2812+is%3Aopen
This commit is contained in:
@ -51,7 +51,9 @@ bh_hash_map_create(uint32 size, bool use_lock, HashFunc hash_func,
|
||||
+ sizeof(HashMapElem *) * (uint64)size
|
||||
+ (use_lock ? sizeof(korp_mutex) : 0);
|
||||
|
||||
if (total_size >= UINT32_MAX || !(map = BH_MALLOC((uint32)total_size))) {
|
||||
/* size <= HASH_MAP_MAX_SIZE, so total_size won't be larger than
|
||||
UINT32_MAX, no need to check integer overflow */
|
||||
if (!(map = BH_MALLOC((uint32)total_size))) {
|
||||
LOG_ERROR("HashMap create failed: alloc memory failed.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user