Commit 97e0751
committed
Fix writeString(Reader, int) to avoid large upfront allocation
When a non-negative length hint is supplied, the previous code allocated
new char[len] upfront — an unbounded allocation if the caller passed a
large value. Replace it with chunked reading (8192-char buffer) into a
StringBuilder, matching the pattern already used in the len<0 branch.1 parent 5a774c4 commit 97e0751
1 file changed
Lines changed: 9 additions & 6 deletions
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
598 | 600 | | |
599 | 601 | | |
600 | 602 | | |
601 | | - | |
| 603 | + | |
| 604 | + | |
602 | 605 | | |
603 | | - | |
| 606 | + | |
604 | 607 | | |
605 | 608 | | |
606 | 609 | | |
| |||
0 commit comments