Skip to content

fix int overflow in Allocator.array/arrayList size checks#551

Open
alhudz wants to merge 1 commit into
apache:masterfrom
alhudz:allocator-array-int-overflow
Open

fix int overflow in Allocator.array/arrayList size checks#551
alhudz wants to merge 1 commit into
apache:masterfrom
alhudz:allocator-array-int-overflow

Conversation

@alhudz
Copy link
Copy Markdown

@alhudz alhudz commented Jun 2, 2026

Allocator.array and arrayList compute the byte cost with a plain int multiply (request * eltShallowByteSize, 24 + request * 4) before handing it to check, while every typed-array helper goes through the overflow-checked check(int, int). A large count read from an image (e.g. an ICC TagCount in IccProfileParser) overflows int to a small or negative value and slips past the 1 GB limit, allocating well beyond it. Route both through check(request, elementSize) so the same multiplyExact guard applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant