8271732: Regression in StringBuilder.charAt bounds checking

Reviewed-by: alanb, naoto
This commit is contained in:
Claes Redestad 2021-08-12 07:01:53 +00:00
parent ec2fc384e5
commit a15b659278
3 changed files with 108 additions and 2 deletions

View file

@ -349,10 +349,11 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
*/
@Override
public char charAt(int index) {
checkIndex(index, count);
if (isLatin1()) {
return StringLatin1.charAt(value, index);
return (char)(value[index] & 0xff);
}
return StringUTF16.charAt(value, index);
return StringUTF16.getChar(value, index);
}
/**