summaryrefslogtreecommitdiff
path: root/std/io/bufio.ts
diff options
context:
space:
mode:
authoruki00a <uki00a@gmail.com>2020-05-20 23:34:20 +0900
committerGitHub <noreply@github.com>2020-05-20 16:34:20 +0200
commit9b4da88a96ce4c793e7b15d9b340fa6326a29a82 (patch)
treec1749398932a769be55022e83b50002d40702c5b /std/io/bufio.ts
parentef14d62462d7f5bc2f091c3521409b4a16c5f87c (diff)
fix(std/io): BufReader should not share the internal buffer across reads (#4543)
Diffstat (limited to 'std/io/bufio.ts')
-rw-r--r--std/io/bufio.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/std/io/bufio.ts b/std/io/bufio.ts
index aa74809fe..5c005672a 100644
--- a/std/io/bufio.ts
+++ b/std/io/bufio.ts
@@ -338,7 +338,11 @@ export class BufReader implements Reader {
// Buffer full?
if (this.buffered() >= this.buf.byteLength) {
this.r = this.w;
- throw new BufferFullError(this.buf);
+ // #4521 The internal buffer should not be reused across reads because it causes corruption of data.
+ const oldbuf = this.buf;
+ const newbuf = this.buf.slice(0);
+ this.buf = newbuf;
+ throw new BufferFullError(oldbuf);
}
s = this.w - this.r; // do not rescan area we scanned before