RFR: 8366421: ModifiedUtf.utfLen may overflow for giant string
Guanqiang Han
ghan at openjdk.org
Mon Sep 15 07:41:23 UTC 2025
Please review this patch.
**Description:**
Currently, ModifiedUtf.utfLen returns a signed int. For very large strings, this may overflow and produce negative values, leading to incorrect behavior in code that relies on the UTF length. This patch changes the return type to long, which fully resolves the issue and allows safe handling of giant strings.
**Test:**
GHA
-------------
Commit messages:
- Change return type of utfLen to long to prevent overflow
Changes: https://git.openjdk.org/jdk/pull/27285/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27285&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8366421
Stats: 24 lines in 4 files changed: 5 ins; 3 del; 16 mod
Patch: https://git.openjdk.org/jdk/pull/27285.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27285/head:pull/27285
PR: https://git.openjdk.org/jdk/pull/27285
More information about the core-libs-dev
mailing list