diff --git a/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java b/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java index 92bec9f944a..3b6401b6d7b 100644 --- a/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java +++ b/jdk/src/share/classes/sun/awt/image/IntegerComponentRaster.java @@ -654,9 +654,6 @@ public class IntegerComponentRaster extends SunWritableRaster { ") 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 @@ public class IntegerComponentRaster extends SunWritableRaster { } 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 + " )"); } }