Skip to content

Commit

Permalink
Explain what on cthulu's blue sea is going on with that n != 0 condition
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Feb 2, 2024
1 parent 35126fe commit 6ac4b54
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rc-zip/src/fsm/entry/lzma_dec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ impl Decompressor for LzmaDec {
// if we haven't written all the input, and we haven't gotten
// any output, then we need to keep going
if n != 0 && n < in_buf.len() && self.internal_buf_mut().is_empty() {
// note: the n != 0 here is because apparently there can be a 10-byte
// trailer after LZMA compressed data? and the decoder will _refuse_
// to let us write them, so when we have just these 10 bytes left,
// it's good to just let the decoder finish up.
trace!("LzmaDec: didn't write all output AND no output yet, so keep going");
return self.decompress(&in_buf[n..], out, has_more_input);
}
Expand Down

0 comments on commit 6ac4b54

Please sign in to comment.