Fix buffer overflow in Sink for Vec<u8>

Fixes #46
This commit is contained in:
Stefan Bühler
2016-09-03 13:25:40 -07:00
committed by Carl Lerche
parent d0d27bd540
commit f693e038d9
2 changed files with 16 additions and 2 deletions
+3 -2
View File
@@ -407,12 +407,13 @@ impl<'a> Sink for &'a mut Vec<u8> {
self.clear();
let rem = buf.remaining();
let cap = self.capacity();
// Ensure that the vec is big enough
if rem > self.capacity() {
self.reserve(rem - cap);
// current length is 0, so reserve completely
self.reserve(rem);
}
debug_assert!(rem <= self.capacity());
unsafe {
{