From 69a226a98c554fd3c999534cf83729774d51f77a Mon Sep 17 00:00:00 2001 From: ptweezy Date: Tue, 27 Oct 2026 16:11:35 -0400 Subject: [PATCH] Test bufsize values of 0 and -1 in decompress() 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. --- tests/test_compat.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_compat.py b/tests/test_compat.py index 55487c8e..3f339851 100644 --- a/tests/test_compat.py +++ b/tests/test_compat.py @@ -20,7 +20,7 @@ import zlib from pathlib import Path -from isal import igzip, isal_zlib +from isal import igzip, igzip_lib, isal_zlib import pytest @@ -129,6 +129,16 @@ def test_decompress_isal_zlib(data_size, level): assert decompressed == data +@pytest.mark.parametrize("module", [isal_zlib, igzip_lib]) +def test_decompress_bufsize(module): + data = DATA[:10_000] + compressed = module.compress(data) + # Like zlib.decompress, decompress accepts a bufsize of 0. + assert module.decompress(compressed, bufsize=0) == data + with pytest.raises(ValueError, match="bufsize must be non-negative"): + module.decompress(compressed, bufsize=-1) + + @pytest.mark.parametrize(["data_size", "level", "wbits", "memLevel"], list(itertools.product([128 * 1024], range(4), WBITS_RANGE, range(1, 10))))