summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2007-03-23 18:01:41 +0000
committerIulian Dragos <jaguarul@gmail.com>2007-03-23 18:01:41 +0000
commitb7cd34eda4a72102e119a373e3efa54c07d8b489 (patch)
tree5697c4f5eaee11da2b4d7ae54449c600406c0e18 /src
parent22fa9933896b195e92911b68369d5d7c607e616b (diff)
downloadscala-b7cd34eda4a72102e119a373e3efa54c07d8b489.tar.gz
scala-b7cd34eda4a72102e119a373e3efa54c07d8b489.tar.bz2
scala-b7cd34eda4a72102e119a373e3efa54c07d8b489.zip
Fixed ArrayIndexOutOfBounds in cached bigints f...
Fixed ArrayIndexOutOfBounds in cached bigints for negative numbers.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/BigInt.scala5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/library/scala/BigInt.scala b/src/library/scala/BigInt.scala
index 09f5fa08f2..0878d0d7aa 100644
--- a/src/library/scala/BigInt.scala
+++ b/src/library/scala/BigInt.scala
@@ -31,8 +31,9 @@ object BigInt {
*/
def apply(i: Int): BigInt =
if (minCached <= i && i <= maxCached) {
- var n = cache(i)
- if (n eq null) { n = new BigInt(BigInteger.valueOf(i)); cache(i) = n }
+ val offset = i - minCached
+ var n = cache(offset)
+ if (n eq null) { n = new BigInt(BigInteger.valueOf(i)); cache(offset) = n }
n
} else new BigInt(BigInteger.valueOf(i))