diff options
-rw-r--r-- | lib/fjbg.jar.desired.sha1 | 2 | ||||
-rw-r--r-- | src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java | 7 | ||||
-rw-r--r-- | test/files/pos/bug3671.scala | 7 |
3 files changed, 12 insertions, 4 deletions
diff --git a/lib/fjbg.jar.desired.sha1 b/lib/fjbg.jar.desired.sha1 index c1e938f381..7e1cb1c13e 100644 --- a/lib/fjbg.jar.desired.sha1 +++ b/lib/fjbg.jar.desired.sha1 @@ -1 +1 @@ -92c1fe294100f174502593e5429ef5d5dacd4760 ?fjbg.jar +b73c0c9115d83849bada9a5c361f77745da22e0d ?fjbg.jar diff --git a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java index 69d0436528..f0f61630e6 100644 --- a/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java +++ b/src/fjbg/ch/epfl/lamp/fjbg/JExtendedCode.java @@ -575,12 +575,13 @@ public class JExtendedCode extends JCode { } int keyMin = keys[0], keyMax = keys[keys.length - 1]; - int keyRange = keyMax - keyMin + 1; + /** Calculate in long to guard against overflow. */ + long keyRange = (long)keyMax - keyMin + 1; if ((double)keys.length / (double)keyRange >= minDensity) { // Keys are dense enough, use a table in which holes are // filled with defaultBranch. - int[] newKeys = new int[keyRange]; - Label[] newBranches = new Label[keyRange]; + int[] newKeys = new int[(int)keyRange]; + Label[] newBranches = new Label[(int)keyRange]; int oldPos = 0; for (int i = 0; i < keyRange; ++i) { int key = keyMin + i; diff --git a/test/files/pos/bug3671.scala b/test/files/pos/bug3671.scala new file mode 100644 index 0000000000..1ca9327bb7 --- /dev/null +++ b/test/files/pos/bug3671.scala @@ -0,0 +1,7 @@ +object Crash { + def crash(value: Int): Unit = + value match { + case java.lang.Integer.MAX_VALUE => println("MAX_VALUE") + case java.lang.Integer.MIN_VALUE => println("MIN_VALUE") + } +}
\ No newline at end of file |