8221307: String.substring() OOB exception on start index reports improper information

Reviewed-by: rriggs, redestad
This commit is contained in:
Ivan Gerasimov 2019-08-16 11:35:17 -07:00
parent a073e1261b
commit c0b8844dce
3 changed files with 50 additions and 16 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -489,7 +489,7 @@ final class StringUTF16 {
final char lo = Character.lowSurrogate(ch);
checkBoundsBeginEnd(fromIndex, max, value);
for (int i = fromIndex; i < max - 1; i++) {
if (getChar(value, i) == hi && getChar(value, i + 1 ) == lo) {
if (getChar(value, i) == hi && getChar(value, i + 1) == lo) {
return i;
}
}