mirror of
https://github.com/mat-1/azalea.git
synced 2024-09-19 22:52:32 +00:00
don't panic on bad utf8
This commit is contained in:
parent
029fa33f55
commit
61db9f930a
1 changed files with 1 additions and 1 deletions
|
@ -48,7 +48,7 @@ fn read_utf_with_len(buf: &mut impl Read, max_length: u32) -> Result<String, Buf
|
|||
let mut buffer = vec![0; length as usize];
|
||||
buf.read_exact(&mut buffer)
|
||||
.map_err(|_| BufReadError::InvalidUtf8)?;
|
||||
string.push_str(std::str::from_utf8(&buffer).unwrap());
|
||||
string.push_str(std::str::from_utf8(&buffer).map_err(|_| BufReadError::InvalidUtf8)?);
|
||||
if string.len() > length as usize {
|
||||
return Err(BufReadError::StringLengthTooLong { length, max_length });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue