Skip to content

Commit a85079a

Browse files
committed
Check integer overflow for wasm_runtime_wasi_nn_registry_set_args
1 parent b122451 commit a85079a

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

core/iwasm/common/wasm_runtime_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,11 @@ wasm_runtime_wasi_nn_registry_set_args(WASINNRegistry *registry,
18121812
return false;
18131813
}
18141814

1815+
if ((sizeof(uint32_t *) * n_graphs) >= UINT32_MAX) {
1816+
LOG_ERROR("Invalid size for wasm_runtime_malloc.");
1817+
return NULL;
1818+
}
1819+
18151820
registry->n_graphs = n_graphs;
18161821
registry->target = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
18171822
registry->encoding = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);

0 commit comments

Comments
 (0)