From 5ef73e37e6e9451184bcdee68fc03f3790d19905 Mon Sep 17 00:00:00 2001 From: Riccardo Casatta Date: Fri, 20 Oct 2023 10:14:25 +0200 Subject: [PATCH] deserialize_bytes data greater than scratch --- ciborium/src/de/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ciborium/src/de/mod.rs b/ciborium/src/de/mod.rs index 1952a4b..dbc623f 100644 --- a/ciborium/src/de/mod.rs +++ b/ciborium/src/de/mod.rs @@ -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| {