diff --git a/src/buffer.rs b/src/buffer.rs index 0853745483..a6a6ff05a7 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -67,6 +67,8 @@ impl BufReader { let cap = self.buf.capacity(); if self.cap == cap { self.buf.reserve(cmp::min(cap * 4, MAX_BUFFER_SIZE) - cap); + let new = self.buf.capacity() - self.buf.len(); + self.buf.extend(iter::repeat(0).take(new)); } } }