Check integer overflow for wasm_runtime_wasi_nn_registry_set_args

This commit is contained in:
zhanheng1 2026-02-05 17:18:40 +08:00
parent b12245198e
commit a85079a2aa

View File

@ -1812,6 +1812,11 @@ wasm_runtime_wasi_nn_registry_set_args(WASINNRegistry *registry,
return false;
}
if ((sizeof(uint32_t *) * n_graphs) >= UINT32_MAX) {
LOG_ERROR("Invalid size for wasm_runtime_malloc.");
return NULL;
}
registry->n_graphs = n_graphs;
registry->target = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);
registry->encoding = (uint32_t **)wasm_runtime_malloc(sizeof(uint32_t *) * n_graphs);