jdk/src/share/classes/sun/awt/image/BytePackedRaster.java
changeset 16868 b5e2827ecc50
parent 5506 202f599c92aa
child 18246 5d1d50a81438
equal deleted inserted replaced
16402:c766ae777656 16868:b5e2827ecc50
  1366         // Make sure data for Raster is in a legal range
  1366         // Make sure data for Raster is in a legal range
  1367         if (dataBitOffset < 0) {
  1367         if (dataBitOffset < 0) {
  1368             throw new RasterFormatException("Data offsets must be >= 0");
  1368             throw new RasterFormatException("Data offsets must be >= 0");
  1369         }
  1369         }
  1370 
  1370 
       
  1371         /* Need to re-verify the dimensions since a sample model may be
       
  1372          * specified to the constructor
       
  1373          */
       
  1374         if (width <= 0 || height <= 0 ||
       
  1375             height > (Integer.MAX_VALUE / width))
       
  1376         {
       
  1377             throw new RasterFormatException("Invalid raster dimension");
       
  1378         }
       
  1379 
       
  1380 
       
  1381         /*
       
  1382          * pixelBitstride was verified in constructor, so just make
       
  1383          * sure that it is safe to multiply it by width.
       
  1384          */
       
  1385         if ((width - 1) > Integer.MAX_VALUE / pixelBitStride) {
       
  1386             throw new RasterFormatException("Invalid raster dimension");
       
  1387         }
       
  1388 
       
  1389         if (scanlineStride < 0 ||
       
  1390             scanlineStride > (Integer.MAX_VALUE / height))
       
  1391         {
       
  1392             throw new RasterFormatException("Invalid scanline stride");
       
  1393         }
       
  1394 
  1371         int lastbit = (dataBitOffset
  1395         int lastbit = (dataBitOffset
  1372                        + (height-1) * scanlineStride * 8
  1396                        + (height-1) * scanlineStride * 8
  1373                        + (width-1) * pixelBitStride
  1397                        + (width-1) * pixelBitStride
  1374                        + pixelBitStride - 1);
  1398                        + pixelBitStride - 1);
  1375         if (lastbit / 8 >= data.length) {
  1399         if (lastbit < 0 || lastbit / 8 >= data.length) {
  1376             throw new RasterFormatException("raster dimensions overflow " +
  1400             throw new RasterFormatException("raster dimensions overflow " +
  1377                                             "array bounds");
  1401                                             "array bounds");
  1378         }
  1402         }
  1379         if (strictCheck) {
  1403         if (strictCheck) {
  1380             if (height > 1) {
  1404             if (height > 1) {