Details
Suggested remediation
Apply the same hardening already used on the sibling operations, in ScriptArray.cs (Multiply case, :504-508):
- Mirror `array.insert_at`: call
context.StepLoop(span, ref loopStep)inside the fill loop soLoopLimitis enforced; or - **Mirror
string * int:** pre-check the result size with overflow-safe arithmetic before allocating, e.g.if (context.LimitToString > 0 && (long)intModifier * array.Count > context.LimitToString) throw new ScriptRuntimeException(...), and compute the capacity aslong(or reject negative/overflowing products) to remove the integer-overflow path.
Add a regression test that asserts a graceful ScriptRuntimeException for a large multiplier (e.g. [1,2,3,4,5] * 50000000) rather than allowing the allocation to proceed.