6888149: AtomicReferenceArray causes SIGSEGV -> SEGV_MAPERR error
authordl
Tue, 06 Oct 2009 12:20:35 -0700
changeset 5169 a4fcbe0e04e3
parent 4241 7d4f50f3806c
child 5170 17c2a503bf94
child 5175 56d64b1e78f9
6888149: AtomicReferenceArray causes SIGSEGV -> SEGV_MAPERR error Summary: Avoid integer overflow by using long arithmetic Reviewed-by: martin, dholmes
jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java	Tue Nov 17 09:44:43 2009 +0000
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java	Tue Oct 06 12:20:35 2009 -0700
@@ -57,7 +57,7 @@
     private long rawIndex(int i) {
         if (i < 0 || i >= array.length)
             throw new IndexOutOfBoundsException("index " + i);
-        return base + i * scale;
+        return base + (long) i * scale;
     }
 
     /**
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java	Tue Nov 17 09:44:43 2009 +0000
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java	Tue Oct 06 12:20:35 2009 -0700
@@ -56,7 +56,7 @@
     private long rawIndex(int i) {
         if (i < 0 || i >= array.length)
             throw new IndexOutOfBoundsException("index " + i);
-        return base + i * scale;
+        return base + (long) i * scale;
     }
 
     /**
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java	Tue Nov 17 09:44:43 2009 +0000
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java	Tue Oct 06 12:20:35 2009 -0700
@@ -57,7 +57,7 @@
     private long rawIndex(int i) {
         if (i < 0 || i >= array.length)
             throw new IndexOutOfBoundsException("index " + i);
-        return base + i * scale;
+        return base + (long) i * scale;
     }
 
     /**