On Wed, 27 May 2026 00:06:33 GMT, Phil Race <[email protected]> wrote:

>> The bug was filed to note that the constructor for 
>> MultiPixelPackedSampleModel could throw an odd exception if numberOfBits is 
>> zero.
>> Per the spec this should throw RasterFormatException.
>> 
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Phil Race has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   8381007

src/java.desktop/share/classes/java/awt/image/MultiPixelPackedSampleModel.java 
line 132:

> 130:                         DataBuffer.getDataTypeSize(dataType));
> 131:         if (sls < 0) {
> 132:             throw new RasterFormatException("Pixels do not fit");

Current implementations can still throw `IllegalArgumentException: 
scanlineStride must be > 0`, e.g. for
`new Args4(TYPE_BYTE, 32, 1, 1<<30, RasterFormatException.class)`

I think we can fix this by declaring `sls` as `long` and checking that it is 
not less than `0` and not greater than `Integer.MAX_VALUE`. Only after that we 
should cast it to `int` in the `this()` call.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/30826#discussion_r3314689288

Reply via email to