8011248: Better Component Rasters
authorprr
Mon, 08 Apr 2013 13:29:19 -0700
changeset 18225 35a86d260c7b
parent 18224 95b6fb2f35a0
child 18226 5d1f8fdc54d8
8011248: Better Component Rasters Reviewed-by: bae, vadim, mschoene
jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java
--- a/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java	Mon Apr 08 21:12:28 2013 +0100
+++ b/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java	Mon Apr 08 13:29:19 2013 -0700
@@ -654,9 +654,6 @@
                                             ") must be >= 0");
         }
 
-        int maxSize = 0;
-        int size;
-
         // we can be sure that width and height are greater than 0
         if (scanlineStride < 0 ||
             scanlineStride > (Integer.MAX_VALUE / height))
@@ -682,21 +679,23 @@
         }
         lastPixelOffset += lastScanOffset;
 
+        int index;
+        int maxIndex = 0;
         for (int i = 0; i < numDataElements; i++) {
             if (dataOffsets[i] > (Integer.MAX_VALUE - lastPixelOffset)) {
                 throw new RasterFormatException("Incorrect band offset: "
                             + dataOffsets[i]);
             }
 
-            size = lastPixelOffset + dataOffsets[i];
+            index = lastPixelOffset + dataOffsets[i];
 
-            if (size > maxSize) {
-                maxSize = size;
+            if (index > maxIndex) {
+                maxIndex = index;
             }
         }
-        if (data.length < maxSize) {
-            throw new RasterFormatException("Data array too small (should be "
-                    + maxSize + " )");
+        if (data.length <= maxIndex) {
+            throw new RasterFormatException("Data array too small (should be > "
+                    + maxIndex + " )");
         }
     }