On Tue, 13 Oct 2026 18:00:03 GMT, Phil Race <[email protected]> wrote:

>> src/java.desktop/share/native/libjavajpeg/imageioJPEG.c line 728:
>> 
>>> 726: 
>>> 727:         for (j = 0; j < 64; j++) {
>>> 728:             quant_ptr->quantval[j] = (UINT16)qdataBody[j];
>> 
>> Converting the values from "int" to "unsigned short" can cause issues.
>> 65536 can become 0 and then we clamp it to 1. We can just clamp directly 
>> without using UINT16 cast.
>
> The definition is
>   UINT16 quantval[DCTSIZE2];    /* quantization step for each coefficient */
> 
> so the cast is reasonable and might even be required by some compiler.
> And it wouldn't change that we need the extra checks.

I think it should be clamped first and then cast? since "65536 -> 0 -> 1" but 
"-1 -> 65535 -> 255"

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33217#discussion_r4263692752

Reply via email to