Ensure the initial string has correct size#9373
Merged
Merged
Conversation
The initial string here was created using the size estimate from the IR, but that number does not appear to include the first string used to start the buffer. The logic then incorrectly allocated an array of initial size but used the first string's real size as the size for the ByteList. In the case reported, this resulted in the buffer ByteList containing a shorter array than the size it claimed, eventually leading to an ArrayIndexOutOfBounds error. The change here fixes the incorrect use of the first string's real size with the buffer as well as always ensuring the buffer has enough room for that initial string plus the estimate. We will want to review how these estimates are being calculated, since it seems there's some confusion as to what is included. Fixes jruby#9372 See also jruby#9046
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.
The initial string here was created using the size estimate from the IR, but that number does not appear to include the first string used to start the buffer. The logic then incorrectly allocated an array of initial size but used the first string's real size as the size for the ByteList. In the case reported, this resulted in the buffer ByteList containing a shorter array than the size it claimed, eventually leading to an ArrayIndexOutOfBounds error.
The change here fixes the incorrect use of the first string's real size with the buffer as well as always ensuring the buffer has enough room for that initial string plus the estimate. We will want to review how these estimates are being calculated, since it seems there's some confusion as to what is included.
Fixes #9372
See also #9046