Fix potential integer overflow issues (#4429)

It is reported as "Multiplication result converted to larger type".
And "Multiplication result may overflow 'Type A' before it is
converted to 'Type B'." Type A is a larger type than Type B.

Since the conversion applies after the multiplication, arithmetic
overflow may still occur.

> The rule flags every multiplication of two non-constant integer expressions
> that is (explicitly or implicitly) converted to a larger integer type. The
> conversion is an indication that the expression would produce a result that
> would be too large to fit in the smaller integer type.
This commit is contained in:
liang.he
2025-07-01 13:39:30 +08:00
committed by GitHub
parent 8949797c84
commit c7148a6823
5 changed files with 8 additions and 6 deletions

View File

@ -301,7 +301,8 @@ wasm_cluster_create(WASMExecEnv *exec_env)
aux_stack_start -= cluster->stack_size;
for (i = 0; i < cluster_max_thread_num; i++) {
cluster->stack_tops[i] = aux_stack_start - cluster->stack_size * i;
cluster->stack_tops[i] =
aux_stack_start - (uint64)cluster->stack_size * i;
}
}
#endif