changeset 5963:4c3d38927a26

8011248: Better Component Rasters Reviewed-by: bae, vadim, mschoene
author prr
date Mon, 08 Apr 2013 12:41:09 -0700
parents 8ab8387ae741
children 3cd4bec64e31
files src/share/classes/sun/awt/image/IntegerComponentRaster.java
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/awt/image/IntegerComponentRaster.java	Fri Apr 05 21:34:42 2013 +0100
+++ b/src/share/classes/sun/awt/image/IntegerComponentRaster.java	Mon Apr 08 12:41:09 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 + " )");
         }
     }