mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
codec: fix infinite loop in tokio_codec::LinesCodec (#1489)
This commit is contained in:
@@ -188,6 +188,21 @@ fn lines_decoder_max_length_newline_between_decodes() {
|
||||
assert_eq!("hello", codec.decode(buf).unwrap().unwrap());
|
||||
}
|
||||
|
||||
// Regression test for [infinite loop bug](https://github.com/tokio-rs/tokio/issues/1483)
|
||||
#[test]
|
||||
fn lines_decoder_discard_repeat() {
|
||||
const MAX_LENGTH: usize = 1;
|
||||
|
||||
let mut codec = LinesCodec::new_with_max_length(MAX_LENGTH);
|
||||
let buf = &mut BytesMut::new();
|
||||
|
||||
buf.reserve(200);
|
||||
buf.put("aa");
|
||||
assert!(codec.decode(buf).is_err());
|
||||
buf.put("a");
|
||||
assert!(codec.decode(buf).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lines_encoder() {
|
||||
let mut codec = LinesCodec::new();
|
||||
|
||||
Reference in New Issue
Block a user