Make CompoundBody consumption past end idempotent

This commit is contained in:
Tony Garnock-Jones 2020-05-29 10:58:40 +02:00
parent d1a5389060
commit 65b5399dbe
1 changed files with 4 additions and 0 deletions

View File

@ -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),
}
}