(0.48.0) Fall back to out-of-line call to StringUTF16.toBytes #20020
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 implementation of
StringUTF16.toBytes
will throw aNegativeArraySizeException
if the specified array length is negative or anOutOfMemoryError
if the length is 2^30 or greater. The IL for the inline implementation that the JIT compiler generates for that recognized method could throw aNegativeArraySizeException
in situations where the actual implementation would throw anOutOfMemoryError
.This change calls the actual implementation if the array length is outside the range [0,0x3fffffff] to ensure that the behaviour is always as expected in exceptional situations.
Port of pull request #19953 to v0.48.0-release branch for issue #19309