You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LOG_ERROR("HashMap find elem failed: map or key is NULL.\n");
returnNULL;
}
if (map->lock) {
os_mutex_lock(map->lock);
}
index=map->hash_func(key) % map->size;
elem=map->elements[index];
while (elem) {
if (map->key_equal_func(elem->key, key)) {
value=elem->value;
if (map->lock) {
os_mutex_unlock(map->lock);
}
returnvalue;
}
elem=elem->next;
}
if (map->lock) {
os_mutex_unlock(map->lock);
}
returnNULL;
}
In the above code, map ->size may be equal to zero, so there may be an exception of divide by zero.
Although all the places where the bh_hash_map_create function is used have a non-zero size, I think it is still necessary to detect the size inside the hashmap in order to enhance the robustness of the code.
The text was updated successfully, but these errors were encountered:
Limit the minimal size of bh_hashmap to avoid creating hashmap with size 0,
and `divide by zero` when calling bh_hash_map_find.
Reported by bytecodealliance#2008.
wasm-micro-runtime/core/shared/utils/bh_hashmap.c
Lines 123 to 157 in e6a0184
In the above code,
map ->size
may be equal to zero, so there may be an exception ofdivide by zero
.Although all the places where the
bh_hash_map_create
function is used have a non-zero size, I think it is still necessary to detect the size inside the hashmap in order to enhance the robustness of the code.The text was updated successfully, but these errors were encountered: