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 #96
  • Loading branch information
naufraghi authored May 29, 2023
1 parent 3032f37 commit 1db557d
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 @@ -224,7 +224,8 @@ impl<W: Write> BzDecoder<W> {
/// Attempts to write data to this stream may result in a panic after this
/// function is called.
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 {
self.write(&[])?;
}
self.dump()
Expand Down

0 comments on commit 1db557d

Please sign in to comment.