Skip to content

Commit

Permalink
Avoid infinite loop writing and empty buffer
Browse files Browse the repository at this point in the history
In `write::BzDecoder::try_finish` do not loop if nothing was written

Closes trifectatechfoundation#96
  • Loading branch information
naufraghi authored and bjorn3 committed Dec 11, 2024
1 parent 090227a commit e764e88
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ impl<W: Write> BzDecoder<W> {
///
/// [`write`]: Self::write
pub fn try_finish(&mut self) -> io::Result<()> {
while !self.done {
// If nothing was written, there is no need to loop
while !self.done && self.total_in() > 0 {
let _ = self.write(&[])?;
}
self.dump()
Expand Down

0 comments on commit e764e88

Please sign in to comment.