changeset 2375:d3309aae68ef

6888149: AtomicReferenceArray causes SIGSEGV -> SEGV_MAPERR error Summary: Avoid integer overflow by using long arithmetic Reviewed-by: martin, dholmes
author dl
date Tue, 06 Oct 2009 12:20:35 -0700
parents 9afe87deb51b
children 08f57141c305 df3091222715
files src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
diffstat 3 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java	Tue Nov 17 09:44:43 2009 +0000
+++ b/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/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java	Tue Nov 17 09:44:43 2009 +0000
+++ b/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/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java	Tue Nov 17 09:44:43 2009 +0000
+++ b/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;
     }
 
     /**