Visitar URL original
zlib: return output inflate still holds after the last input byte by JMLX42 路 Pull Request #8909 路 RustPython/RustPython 路 GitHub
Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
zlib: fold the full-buffer case into the loop's exit condition
Return when the stream ended, or when the input is used up and inflate
left part of the output buffer empty. A full buffer falls through to
the existing next iteration, as CPython's loop runs while avail_out is
zero, instead of a separate branch ahead of the exit check.

Assisted-by: Claude Code:claude-opus-5-5
  • Loading branch information
JMLX42 committed Sep 29, 2026
commit a70643b8dcbd36518b8fdf608996295a0edb576c
9 changes: 3 additions & 6 deletions crates/common/src/compression/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,9 @@ fn decompress_chunks(
match res {
Ok(status) => {
let stream_end = status == Status::StreamEnd;
if produced == additional && !stream_end {
// A full output buffer can leave output pending in
// inflate, even with no input left.
continue 'outer;
}
if stream_end || data.is_empty() {
// A full output buffer can leave output pending in inflate,
// even with no input left: only a partial buffer ends it.
if stream_end || (data.is_empty() && produced < additional) {
buf.shrink_to_fit();
return Ok((buf, stream_end));
} else if !chunk.is_empty() && consumed == 0 {
Expand Down
Loading