mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 13:16:26 +00:00
Check arguments before calling bh_hash_map_find (#3055)
Check whether the arguments are NULL before calling bh_hash_map_find, or lots of "HashMap find elem failed: map or key is NULL" warnings may be dumped. Reported in #3053.
This commit is contained in:
parent
17b0111577
commit
ec6d9cb6be
|
@ -176,7 +176,8 @@ acquire_wait_info(void *address, AtomicWaitNode *wait_node)
|
||||||
AtomicWaitInfo *wait_info = NULL;
|
AtomicWaitInfo *wait_info = NULL;
|
||||||
bh_list_status ret;
|
bh_list_status ret;
|
||||||
|
|
||||||
if (address)
|
bh_assert(address != NULL);
|
||||||
|
|
||||||
wait_info = (AtomicWaitInfo *)bh_hash_map_find(wait_map, address);
|
wait_info = (AtomicWaitInfo *)bh_hash_map_find(wait_map, address);
|
||||||
|
|
||||||
if (!wait_node) {
|
if (!wait_node) {
|
||||||
|
|
|
@ -468,7 +468,7 @@ get_thread_info(wasm_exec_env_t exec_env, uint32 handle)
|
||||||
WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env);
|
WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env);
|
||||||
ClusterInfoNode *info = get_cluster_info(cluster);
|
ClusterInfoNode *info = get_cluster_info(cluster);
|
||||||
|
|
||||||
if (!info) {
|
if (!info || !handle) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,6 +1144,10 @@ sem_open_wrapper(wasm_exec_env_t exec_env, const char *name, int32 oflags,
|
||||||
* For Unix like system, it's dedicated for multiple processes.
|
* For Unix like system, it's dedicated for multiple processes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if (!name) { /* avoid passing NULL to bh_hash_map_find and os_sem_open */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((info_node = bh_hash_map_find(sem_info_map, (void *)name))) {
|
if ((info_node = bh_hash_map_find(sem_info_map, (void *)name))) {
|
||||||
return info_node->handle;
|
return info_node->handle;
|
||||||
}
|
}
|
||||||
|
@ -1276,7 +1280,13 @@ sem_unlink_wrapper(wasm_exec_env_t exec_env, const char *name)
|
||||||
(void)exec_env;
|
(void)exec_env;
|
||||||
int32 ret_val;
|
int32 ret_val;
|
||||||
|
|
||||||
ThreadInfoNode *info_node = bh_hash_map_find(sem_info_map, (void *)name);
|
ThreadInfoNode *info_node;
|
||||||
|
|
||||||
|
if (!name) { /* avoid passing NULL to bh_hash_map_find */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
info_node = bh_hash_map_find(sem_info_map, (void *)name);
|
||||||
if (!info_node || info_node->type != T_SEM)
|
if (!info_node || info_node->type != T_SEM)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user