summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNadeem Vawda <nadeem.vawda@gmail.com>2012-11-11 02:15:32 (GMT)
committerNadeem Vawda <nadeem.vawda@gmail.com>2012-11-11 02:15:32 (GMT)
commit7ee955550b27af117ddca61deb061e13423cf24b (patch)
tree5af7af0e38d0a8163b651250cf5b0c70c76253cc /Lib/test
parentee7889dec321654d1c50448de7987e1841dd3ad5 (diff)
downloadcpython-7ee955550b27af117ddca61deb061e13423cf24b.zip
cpython-7ee955550b27af117ddca61deb061e13423cf24b.tar.gz
cpython-7ee955550b27af117ddca61deb061e13423cf24b.tar.bz2
Issue #16411: Fix a bug where zlib.decompressobj().flush() might try to access previously-freed memory.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_zlib.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index 6d4b2c3..4661c1d 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -459,6 +459,18 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
self.assertEqual(dco.unconsumed_tail, b'')
self.assertEqual(dco.unused_data, remainder)
+ def test_flush_with_freed_input(self):
+ # Issue #16411: decompressor accesses input to last decompress() call
+ # in flush(), even if this object has been freed in the meanwhile.
+ input1 = b'abcdefghijklmnopqrstuvwxyz'
+ input2 = b'QWERTYUIOPASDFGHJKLZXCVBNM'
+ data = zlib.compress(input1)
+ dco = zlib.decompressobj()
+ dco.decompress(data, 1)
+ del data
+ data = zlib.compress(input2)
+ self.assertEqual(dco.flush(), input1[1:])
+
if hasattr(zlib.compressobj(), "copy"):
def test_compresscopy(self):
# Test copying a compression object