alloca with a variable size can exhaust the stack and cause overflow.
Use heap allocation with a validated bounded size instead of alloca.