Skip to content

Commit

Permalink
Fix potential offset errors in BasicJsonParser
Browse files Browse the repository at this point in the history
Update BasicJsonParser to fix potential exceptions if strings happen
to be empty.

Fixes spring-projectsgh-6136
  • Loading branch information
isopov authored and philwebb committed Jun 10, 2016
1 parent ed6f11d commit 1528764
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ private Object parseInternal(String json) {
}

private static String trimTrailingCharacter(String string, char c) {
if (string.length() >= 0 && string.charAt(string.length() - 1) == c) {
if (string.length() > 0 && string.charAt(string.length() - 1) == c) {
return string.substring(0, string.length() - 1);
}
return string;
}

private static String trimLeadingCharacter(String string, char c) {
if (string.length() >= 0 && string.charAt(0) == c) {
if (string.length() > 0 && string.charAt(0) == c) {
return string.substring(1);
}
return string;
Expand Down

0 comments on commit 1528764

Please sign in to comment.