On Wed, 11 Mar 2026 12:01:01 GMT, Shaojin Wen <[email protected]> wrote:
> The encodedLengthUTF8() method uses an int accumulator (dp) for the LATIN1 > code path, while the UTF16 path (encodedLengthUTF8_UTF16) correctly uses a > long accumulator with an overflow check. When a LATIN1 string contains more > than Integer.MAX_VALUE/2 non-ASCII bytes, the int dp overflows, potentially > causing NegativeArraySizeException in downstream buffer allocation. > > Fix: change dp from int to long and add the same overflow check used in the > UTF16 path. > > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/jdk/pull/30189
