Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Java] Fix overflow issue when requesting large buffer size. #538

Merged
merged 1 commit into from
Aug 7, 2018
Merged

[Java] Fix overflow issue when requesting large buffer size. #538

merged 1 commit into from
Aug 7, 2018

Conversation

epickrram
Copy link
Contributor

Fixes an infinite loop when calculated newCapacity overflows:

final int newCapacity = Math.max(capacity + (capacity >> 1), MIN_ALLOCATED_CAPACITY);
// newCapacity is never negative, as Math.max returns MIN_ALLOCATED_CAPACITY
// when capacity + (capacity >> 1) overflows
if (newCapacity < 0 || newCapacity > MAX_CAPACITY)

Extracted utility method out to separate class to facilitate testing.

@mjpt777 mjpt777 merged commit 0bdb6c7 into real-logic:master Aug 7, 2018
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.

2 participants