提交 060b01b5 编写于 作者: C chegar

8134424: BlockDataInputStream.readUTFBody: size local StringBuffer with the given length

Reviewed-by: rriggs, shade
上级 4163a25e
...@@ -3403,7 +3403,15 @@ public class ObjectInputStream ...@@ -3403,7 +3403,15 @@ public class ObjectInputStream
* utflen bytes. * utflen bytes.
*/ */
private String readUTFBody(long utflen) throws IOException { 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) { if (!blkmode) {
end = pos = 0; end = pos = 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册