Skip to content
Snippets Groups Projects
Commit 01106f6a authored by Kurt Partridge's avatar Kurt Partridge
Browse files

fix IllegalOutOfBoundsException

StringUtils.toCodePointArray() had thrown IllegalOutOfBoundsException if
passed an empty string.  change to just return an empty int[].

Bug: 6188932
Change-Id: Ic41c628c0d407f49fc98cd48cb7ea13d8d5bdd77
parent 73680097
No related branches found
No related tags found
No related merge requests found
...@@ -184,6 +184,9 @@ public class StringUtils { ...@@ -184,6 +184,9 @@ public class StringUtils {
final char[] characters = string.toCharArray(); final char[] characters = string.toCharArray();
final int length = characters.length; final int length = characters.length;
final int[] codePoints = new int[Character.codePointCount(characters, 0, length)]; final int[] codePoints = new int[Character.codePointCount(characters, 0, length)];
if (length <= 0) {
return new int[0];
}
int codePoint = Character.codePointAt(characters, 0); int codePoint = Character.codePointAt(characters, 0);
int dsti = 0; int dsti = 0;
for (int srci = Character.charCount(codePoint); for (int srci = Character.charCount(codePoint);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment