Fixed out of bounds bug
This commit is contained in:
parent
72dbd5cbab
commit
b4a6ae1cb0
@ -1,4 +1,4 @@
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Format {
|
||||
Bold,
|
||||
Italics,
|
||||
@ -23,7 +23,7 @@ impl std::fmt::Display for Format {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Color {
|
||||
White,
|
||||
Black,
|
||||
|
@ -640,13 +640,15 @@ async fn recv<T: AsyncRead>(
|
||||
let len = new_lines.len();
|
||||
|
||||
for (index, line) in new_lines.into_iter().enumerate() {
|
||||
if buf.len() < 2 {
|
||||
continue;
|
||||
}
|
||||
if index == len - 1 && &buf[buf.len() - 2..] != b"\r\n" {
|
||||
*partial_line = line.to_owned();
|
||||
break;
|
||||
}
|
||||
if line.len() != 0 {
|
||||
lines.push(line.to_owned());
|
||||
}
|
||||
|
||||
lines.push(line.to_owned());
|
||||
}
|
||||
Ok(lines)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user