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

BogusColorSpace methods return wrong array

XMLWordPrintable

      Methods toRGB, fromRGB, toCIEXYZ, and fromCIEXYZ of com.sun.imageio.plugins.common.BogusColorSpace class create a new array but return the original one. E.g., consider toRGB:

           public float[] toRGB(float[] colorvalue) {
              if(colorvalue.length < getNumComponents()) {
                  throw new ArrayIndexOutOfBoundsException
                      ("colorvalue.length < getNumComponents()");
              }

              float[] rgbvalue = new float[3];

              System.arraycopy(colorvalue, 0, rgbvalue, 0,
                               Math.min(3, getNumComponents()));

              return colorvalue;
          }

      It returns colorvalue while rgbvalue should be returned instead. This may violate the specification of ColorSpace::toRGB as it states that an array of length 3 must be returned while the input array is not constrained and may have a different length. The same problem exists in other methods of this class.

            prr Philip Race
            tvaleev Tagir Valeev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: