From 6667f1bfcd5ba036663587b8ec9ce7ce0f38e498 Mon Sep 17 00:00:00 2001 From: Olivier ROLAND Date: Tue, 24 Oct 2023 18:49:03 +0200 Subject: [PATCH] Fix infinite loop caused by invalid UTF-8 bytes --- futures-util/src/io/read_line.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/futures-util/src/io/read_line.rs b/futures-util/src/io/read_line.rs index e1b8fc9455..df782c9570 100644 --- a/futures-util/src/io/read_line.rs +++ b/futures-util/src/io/read_line.rs @@ -35,6 +35,7 @@ pub(super) fn read_line_internal( ) -> Poll> { let ret = ready!(read_until_internal(reader, cx, b'\n', bytes, read)); if str::from_utf8(bytes).is_err() { + bytes.clear(); Poll::Ready(ret.and_then(|_| { Err(io::Error::new(io::ErrorKind::InvalidData, "stream did not contain valid UTF-8")) }))