Raster.createBandedRaster(int, int, int, int, int[], int[], Point) does not check for negative scanlineStride

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P3
    • 27
    • Affects Version/s: 17, 21, 25, 26, 27
    • Component/s: client-libs
    • None
    • 2d

      from spec of
       createBandedRaster(int dataType, int w, int h, int scanlineStride, int[] bankIndices, int[] bandOffsets, Point location),
      we have:
       IllegalArgumentException – if scanlineStride is less than 0.

      However, when I tried large negative values such as -1000 or Integer.MIN_VALUE, I encountered a java.lang.NegativeArraySizeException instead of the expected IllegalArgumentException.

      After reviewing the code, I noticed that the exception is thrown before execution reaches the check for scanlineStride < 0. Specifically, it occurs in the following block:

      case DataBuffer.TYPE_BYTE:
          d = new DataBufferByte(size, banks);
          break;

      As a result, the documented exception behavior is not consistently enforced for all negative values of scanlineStride.



      I think this warrants a documentation enhancement to clarify the actual behavior.

            Assignee:
            Philip Race
            Reporter:
            Hamza Nassour
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: