diff --git a/src/stream/read/mod.rs b/src/stream/read/mod.rs index a3a947b0..8a82cc86 100644 --- a/src/stream/read/mod.rs +++ b/src/stream/read/mod.rs @@ -93,7 +93,9 @@ impl<'a, R: BufRead> Decoder<'a, R> { /// /// Calling `finish()` is not *required* after reading a stream - /// just use it if you need to get the `Read` back. - pub fn finish(self) -> R { + pub fn finish(mut self) -> R { + // Ensure the input buffers have been flushed by reading to a zero-length buffer. + let _ = self.reader.read(&mut [0; 0]); self.reader.into_inner() }