SI-7880 Fix infinite loop in ResizableArray#ensureSize

This issue was triggered for values greater than Int.MaxValue/2, which
caused the computation of the new array size to overflow and become
negative, leading to an infinite loop.
Merge pull request #3284 from soc/SI-7880

SI-7880 Fix infinite loop in ResizableArray#ensureSize