mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-14 18:03:44 +00:00
8134424: BlockDataInputStream.readUTFBody: size local StringBuffer with the given length
Reviewed-by: rriggs, shade
This commit is contained in:
parent
7f68f6d847
commit
40965e0d6a
@ -3144,7 +3144,15 @@ public class ObjectInputStream
|
||||
* utflen bytes.
|
||||
*/
|
||||
private String readUTFBody(long utflen) throws IOException {
|
||||
StringBuilder sbuf = new StringBuilder();
|
||||
StringBuilder sbuf;
|
||||
if (utflen > 0 && utflen < Integer.MAX_VALUE) {
|
||||
// a reasonable initial capacity based on the UTF length
|
||||
int initialCapacity = Math.min((int)utflen, 0xFFFF);
|
||||
sbuf = new StringBuilder(initialCapacity);
|
||||
} else {
|
||||
sbuf = new StringBuilder();
|
||||
}
|
||||
|
||||
if (!blkmode) {
|
||||
end = pos = 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user