Skip to content

Test bufsize values of 0 and -1 in decompress() - #307

Merged
rhpvorderman merged 1 commit into
pycompression:developfrom
ptweezy:test-decompress-bufsize
Nov 2, 2026
Merged

rhpvorderman merged 1 commit into
pycompression:developfrom
ptweezy:test-decompress-bufsize

Conversation

@ptweezy

@ptweezy ptweezy commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

isal_zlib.decompress() and igzip_lib.decompress() turn a bufsize of 0 into 1 and raise ValueError for a negative bufsize, as zlib.decompress() does. No test used those values. This PR adds a test for both functions.

To test it, I removed each of the two checks in igzip_lib_decompress_impl() in isal_shared.h. All tests in tests/test_compat.py on develop still pass. Without the line that turns 0 into 1, the output buffer starts at 0 bytes and doubling it leaves it at 0, so decompress() never returns, and the new test doesn't finish (I stopped it after 20 s). Without the check for negative values, the new test fails with SystemError.

This PR changes only tests, so it has no CHANGELOG entry.

Checklist

  • Pull request details were added to CHANGELOG.rst
  • Documentation was updated (if needed)

isal_zlib.decompress() and igzip_lib.decompress() turn a bufsize of 0 into 1 and reject a negative bufsize, as zlib.decompress() does. No test used those values. Without the first check, a bufsize of 0 makes decompress() loop forever.
@rhpvorderman

Copy link
Copy Markdown
Collaborator

Thanks!

@rhpvorderman
rhpvorderman merged commit bb970f1 into pycompression:develop Nov 2, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants