Skip to content

Commit

Permalink
Minor fix to handle invalid strings at peak_name.
Browse files Browse the repository at this point in the history
Fix by K0lb3.
  • Loading branch information
Youjose committed Jul 2, 2023
1 parent a6a2911 commit e11e9e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/read_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ pub trait ReadUrexExt: ReadBytesExt {
}

fn read_string_sized(&mut self, len: usize) -> Result<String, std::io::Error> {
let s = String::from_utf8(self.read_bytes_sized(len).unwrap()).unwrap();
Ok(s)
match String::from_utf8(self.read_bytes_sized(len).unwrap()) {
Ok(s) => Ok(s),
Err(e) => Err(std::io::Error::new(std::io::ErrorKind::InvalidData, e)),
}
}

fn read_bytes<T: ByteOrder>(&mut self) -> Result<Vec<u8>, std::io::Error> {
Expand Down

0 comments on commit e11e9e3

Please sign in to comment.