Skip to content

Commit c64c1d7

Browse files
committed
Fix panic deserializing RawValue from invalid utf-8 bytes
1 parent 2f812d0 commit c64c1d7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/read.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,10 @@ impl<'a> Read<'a> for SliceRead<'a> {
587587
V: Visitor<'a>,
588588
{
589589
let raw = &self.slice[self.raw_buffering_start_index..self.index];
590-
let raw = str::from_utf8(raw).unwrap();
590+
let raw = match str::from_utf8(raw) {
591+
Ok(raw) => raw,
592+
Err(_) => return error(self, ErrorCode::InvalidUnicodeCodePoint),
593+
};
591594
visitor.visit_map(BorrowedRawDeserializer {
592595
raw_value: Some(raw),
593596
})

0 commit comments

Comments
 (0)