diff options
author | Rui Gonçalves <ruippeixotog@gmail.com> | 2015-12-06 19:25:00 +0000 |
---|---|---|
committer | Rui Gonçalves <ruippeixotog@gmail.com> | 2015-12-06 19:25:00 +0000 |
commit | c17b18e173e07f421f9171272d94d84908526609 (patch) | |
tree | 3008e9e5be2acc44a6ffc7e56e84fe91fbcb0cb8 /project | |
parent | 5e99f82159842c5e2b60a1427e129b0b720a0d38 (diff) | |
download | scala-c17b18e173e07f421f9171272d94d84908526609.tar.gz scala-c17b18e173e07f421f9171272d94d84908526609.tar.bz2 scala-c17b18e173e07f421f9171272d94d84908526609.zip |
SI-9581 Fix overflow on Vector take and drop methods
Fixes the index/length comparison in `Vector#take` and `Vector#drop` so that they handle all possible integer values.
Given the collection's invariants `startIndex >= endIndex` and `0 >= startIndex, endIndex`, it is sufficient to change the arithmetic in the comparison as done in this commit to avoid overflows. As cases when `n <= 0` are handled beforehand, `endIndex - n` cannot overflow, contrary to `startIndex + n`. If without the danger of overflows the condition yields true, on the other hand, `startIndex + n` cannot overflow as it is smaller than `endIndex` (as the previous formulation of the condition shows).
Diffstat (limited to 'project')
0 files changed, 0 insertions, 0 deletions