From 65b5399dbe5f26f25b61fc3857797e78ef89d9a1 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Fri, 29 May 2020 10:58:40 +0200 Subject: [PATCH] Make CompoundBody consumption past end idempotent --- implementations/rust/src/value/reader.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/implementations/rust/src/value/reader.rs b/implementations/rust/src/value/reader.rs index e3e0ddf..491ff4d 100644 --- a/implementations/rust/src/value/reader.rs +++ b/implementations/rust/src/value/reader.rs @@ -22,6 +22,7 @@ pub struct CompoundBody { pub enum CompoundLimit { Counted(usize), Streaming, + Finished, } impl CompoundBody { @@ -38,6 +39,7 @@ impl CompoundBody { CompoundLimit::Counted(ref mut n) => if *n == 0 { read.close_compound_counted(self.minor)?; + self.limit = CompoundLimit::Finished; Ok(false) } else { *n = *n - 1; @@ -45,6 +47,8 @@ impl CompoundBody { }, CompoundLimit::Streaming => Ok(!read.close_compound_stream(self.minor)?), + CompoundLimit::Finished => + Ok(false), } }