8212694: Using Raw String Literals with align() and Integer.MIN_VALUE causes out of memory error

Reviewed-by: smarks, sherman
This commit is contained in:
Jim Laskey 2018-10-29 12:31:49 -03:00
parent 6a045adbed
commit 7a9db013b7
2 changed files with 16 additions and 1 deletions

View file

@ -2967,7 +2967,9 @@ public final class String
.mapToInt(String::indexOfNonWhitespace)
.min()
.orElse(0);
return indent(n - outdent, true);
// overflow-conscious code
int indent = n - outdent;
return indent(indent > n ? Integer.MIN_VALUE : indent, true);
}
/**