Skip to content

Commit

Permalink
fix(buffer): zero out new capacity when buffer grows
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Mar 31, 2015
1 parent 6b2e731 commit cfdabd7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ impl<R: Read> BufReader<R> {
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));
}
}
}
Expand Down

0 comments on commit cfdabd7

Please sign in to comment.