Repository navigation
Fix read_to_iter crash with buffer-protocol input - #355
Open
CAOShurong wants to merge 1 commit into
Open
CAOShurong wants to merge 1 commit into
CAOShurong wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #303.
Buffer-protocol input leaves
readResultnull because the iterator holds theinput through its
Py_buffer. If a small output buffer makes compression resumeon the next iteration, consuming the remaining input calls
Py_DECREFon thatnull pointer. Use
Py_XDECREF, matching the initial-feed and deallocation paths.The regression uses 131,073 bytes of deterministic incompressible input with
small output chunks. It covers bytes, bytearray, memoryview and BytesIO, and
checks the complete frame, decompressed data, chunk limits and repeated EOF.
Validated on Windows x64 / CPython 3.13.1 using non-editable source and
sdist-built wheels, with repeated focused/full tests on C and CFFI backends:
C 249 passed / 44 skipped; CFFI 225 passed / 68 skipped. All 292 prior test
outcomes per backend are unchanged. The original native crash, mmap input,
buffer lifetime and error paths were also checked; related iterator fuzzing,
Ruff, mypy, builds and package checks passed. Other platforms and Rust were not
tested.