On Fri, 6 Nov 2026 20:27:33 GMT, Phil Race <[email protected]> wrote:

>> src/java.desktop/share/native/libjavajpeg/jpegdecoder.c line 354:
>> 
>>> 352:     buflen = (*env)->GetArrayLength(env, src->hInputBuffer);
>>> 353:     if (offset > buflen) {
>>> 354:         cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
>> 
>> I don't think we call error_exit is these scenarios.
>> We just return back to the caller(mostly libjpeg code).
>
> @jayathirthrao what did you mean by "these scenarios" ?

We have a pattern of not directly calling error_exit() from fill/suspend buffer 
when we have conditions like ret<=0 or buflen <=0.
We call error_exit() only when we already have an exception or unable to pin 
the arrays.

Initially i thought just returning would be sufficient, but if we just return 
libjpeg will keep on trying to fill the suspended buffer and make no progress.
Also enlarging the Java input buffer to hold the extra EOI byte only for this 
specific scenario is not a good idea.

So its better if we just do error_exit() from these places.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33313#discussion_r4521400451

Reply via email to