Skip to content

Commit eb1d0cc

Browse files
committed
bufread::generic::Decoder: don't reinitialize on reader EOF
If `multiple_members` is enabled, the `bufread::generic::Decoder` will attempt to reinitialise the decoder inside `State::Flushing`, even if the reason it entered that state was due to the reader returning an EOF. This will result in an attempt to read past EOF, which is highly undesirable to say the least. To fix this, force `multiple_members` to `false` when we get an EOF condition from the reader.
1 parent 6104f83 commit eb1d0cc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/futures/bufread/generic/decoder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ impl<R: AsyncBufRead, D: Decode> Decoder<R, D> {
7070
State::Decoding => {
7171
let input = ready!(this.reader.as_mut().poll_fill_buf(cx))?;
7272
if input.is_empty() {
73+
// Avoid attempting to reinitialise the decoder if the reader
74+
// has returned EOF.
75+
*this.multiple_members = false;
7376
State::Flushing
7477
} else {
7578
let mut input = PartialBuffer::new(input);

0 commit comments

Comments
 (0)