alhudz opened a new pull request, #1750:
URL: https://github.com/apache/commons-lang/pull/1750
Repro: `ArrayUtils.reverse(new int[]{1, 2, 3}, 0, Integer.MIN_VALUE)`.
Expected: no change, since the `endIndexExclusive` Javadoc documents an
undervalue `< start index` as no change.
Actual: `ArrayIndexOutOfBoundsException: Index 2147483647 out of bounds for
length 3`.
Cause: `Math.min(array.length, endIndexExclusive) - 1` keeps
`Integer.MIN_VALUE` and the `- 1` underflows to `Integer.MAX_VALUE`, so the
`while (j > i)` loop indexes past the array. All nine primitive and `Object`
range overloads share the line.
Fix: clamp the end to zero before the decrement with the existing `max0`
helper, as the sibling `subarray` and `shift` methods already do. Every other
negative end was already a no-op, so valid ranges are unchanged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]