Fix overflowed arithmetic.

This uses wrapping_add, which was always the intended operation.

Fixes #5275.
This commit is contained in:
Jack Moffitt 2015-03-19 09:31:40 -06:00
parent 34950418ea
commit 331c7030d9

View file

@ -391,7 +391,7 @@ impl<T: Send> Buffer<T> {
// NB: not entirely obvious, but thanks to 2's complement,
// casting delta to usize and then adding gives the desired
// effect.
let buf = Buffer::new(self.log_size + delta as usize);
let buf = Buffer::new(self.log_size.wrapping_add(delta as usize));
for i in range(t, b) {
buf.put(i, self.get(i));
}