Skip to content

Commit

Permalink
deserialize_bytes data greater than scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
RCasatta committed Oct 20, 2023
1 parent 2ac91ce commit 6c618fa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ciborium/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,13 @@ where
return match self.decoder.pull()? {
Header::Tag(..) => continue,

Header::Bytes(Some(len)) if len <= self.scratch.len() => {
self.decoder.read_exact(&mut self.scratch[..len])?;
visitor.visit_bytes(&self.scratch[..len])
Header::Bytes(Some(len)) => {
if len <= self.scratch.len() {
self.decoder.read_exact(&mut self.scratch[..len])?;
visitor.visit_bytes(&self.scratch[..len])
} else {
visitor.visit_byte_buf(vec![0u8; len])
}
}

Header::Array(len) => self.recurse(|me| {
Expand Down

0 comments on commit 6c618fa

Please sign in to comment.