Issue #8650: Backport 64-bit safety fixes for compress() and decompress().

This commit is contained in:
Nadeem Vawda 2011-05-14 22:26:55 +02:00
parent 7619e88adb
commit 1b8a417d9f
2 changed files with 32 additions and 10 deletions

View file

@ -186,6 +186,17 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
def test_big_decompress_buffer(self, size):
self.check_big_decompress_buffer(size, zlib.decompress)
@precisionbigmemtest(size=_4G + 100, memuse=1)
def test_length_overflow(self, size):
if size < _4G + 100:
self.skipTest("not enough free memory, need at least 4 GB")
data = b'x' * size
try:
self.assertRaises(OverflowError, zlib.compress, data, 1)
self.assertRaises(OverflowError, zlib.decompress, data)
finally:
data = None
class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
# Test compression object