Integrated: 8329623: NegativeArraySizeException encoding large String to UTF-8

Roger Riggs rriggs at openjdk.org
Mon Apr 8 18:01:12 UTC 2024


On Fri, 5 Apr 2024 17:44:38 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> When encoding a vary large string in String.getBytes(StandardCharset.UTF_8) computation of the buffer size may exceed the range of a positive 32-bit Integer.
> If the estimated size for the result byte array is too large, pre-compute the exact buffer size. 
> If that exceeds the range, then throw OutOfMemoryError.

This pull request has now been integrated.

Changeset: 212a2536
Author:    Roger Riggs <rriggs at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/212a253697b1a5e722bb90ae1140c91175fc028b
Stats:     78 lines in 2 files changed: 76 ins; 0 del; 2 mod

8329623: NegativeArraySizeException encoding large String to UTF-8

Reviewed-by: naoto, rgiulietti

-------------

PR: https://git.openjdk.org/jdk/pull/18663


More information about the core-libs-dev mailing list