Skip to content

Commit

Permalink
Fix panic deserializing RawValue from invalid utf-8 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Feb 28, 2021
1 parent 2f812d0 commit c64c1d7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,10 @@ impl<'a> Read<'a> for SliceRead<'a> {
V: Visitor<'a>,
{
let raw = &self.slice[self.raw_buffering_start_index..self.index];
let raw = str::from_utf8(raw).unwrap();
let raw = match str::from_utf8(raw) {
Ok(raw) => raw,
Err(_) => return error(self, ErrorCode::InvalidUnicodeCodePoint),
};
visitor.visit_map(BorrowedRawDeserializer {
raw_value: Some(raw),
})
Expand Down

0 comments on commit c64c1d7

Please sign in to comment.