Repository navigation
Conversation
RgbeInfo.getPixelData() checked width * height against the allocation limit as an element count, computed in int, while it allocates three float arrays of that length. A header declaring a large height passed the check and requested up to 12 times the limit before reading any scan line, and a product overflowing int reached the allocation as a negative size. Compute the pixel count as a long and check it against the size of the three float arrays, so both cases throw AllocationRequestException. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes IMAGING-398.
RgbeInfo.getPixelData()allocated its pixel buffer asnew float[3][Allocator.check(wd * ht)]. The check counted elements rather than bytes (the buffer is three float arrays, so up to 12 times the limit), andwd * htwas computed inint, so a large height could also overflow to a negative size and throwNegativeArraySizeException.The size is now computed as a
longand checked withAllocator.check(long, int)against3 * Float.BYTESper pixel, so both cases throwAllocationRequestExceptionbefore anything is allocated. This is the same pattern as the PCX,ImageBuilderand JPEG fixes (#552, #559, #570). Scan-line decoding is unchanged (see #576).A generic memory allocation solution will be introduced in IMAGING-379.
A new parameterized test covers both cases with header-only files; without the change, the first one runs out of heap.
mvn.