Skip to content

Commit 6667f1b

Browse files
newca12taiki-e
authored andcommitted
Fix infinite loop caused by invalid UTF-8 bytes
1 parent 3f9bac5 commit 6667f1b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

futures-util/src/io/read_line.rs

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub(super) fn read_line_internal<R: AsyncBufRead + ?Sized>(
3535
) -> Poll<io::Result<usize>> {
3636
let ret = ready!(read_until_internal(reader, cx, b'\n', bytes, read));
3737
if str::from_utf8(bytes).is_err() {
38+
bytes.clear();
3839
Poll::Ready(ret.and_then(|_| {
3940
Err(io::Error::new(io::ErrorKind::InvalidData, "stream did not contain valid UTF-8"))
4041
}))

0 commit comments

Comments
 (0)