Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8094229

BMPImageLoader fails to correctly load an image if the input stream read(byte[] b, int off, int len) method happens to return fewer than 'len' bytes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8u20
    • fx2.0
    • javafx
    • None

    Description

      See the attached program and bmp file. When the com.sun.javafx.iio.ImageStorage.loadAll() method is given a stream that, when requested 384 bytes, returns fewer than 384 bytes, the image gets loaded incorrectly. I think the problem is in the following code in javafx-iio/src/com/sun/javafx/iio/bmp/BMPImageLoaderFactory.java:

      186 int nRead = data.in.read(image, line * bmpStride, bmpStride);
      187 GBRtoRGB(image, line * bmpStride, nRead);
      188 if (nRead < bmpStride) {
      189 break;
      190 }

      This code seems to assume that InputStream.read(byte[] b, int off, int len) returning fewer than 'len' bytes indicates the end of stream, which is not true per the InputStream.read(byte[] b, int off, int len) spec.

      The test program is supposed to be run with the j2d pipeline.

      Attachments

        Issue Links

          Activity

            People

              vadim Vadim Pakhnushev
              vbaranov Vasiliy Baranov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported: