From 331c7030d9950e7b8c005d78513eda31c264d9d2 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Thu, 19 Mar 2015 09:31:40 -0600 Subject: [PATCH] Fix overflowed arithmetic. This uses wrapping_add, which was always the intended operation. Fixes #5275. --- components/util/deque/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/util/deque/mod.rs b/components/util/deque/mod.rs index 888646a03d1..8ab6726e7dd 100644 --- a/components/util/deque/mod.rs +++ b/components/util/deque/mod.rs @@ -391,7 +391,7 @@ impl Buffer { // 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)); }