diff options
| author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-11-11 02:14:56 (GMT) |
|---|---|---|
| committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2012-11-11 02:14:56 (GMT) |
| commit | 3c30970d2910c6a6411bd8e1c0e2fe1bdfb99726 (patch) | |
| tree | 5891d449abcc2f9b27035b27688b3ac97c91f06d /Lib/test/test_zlib.py | |
| parent | 252f4dc6c9a418f83749bbfe76b672c800e6a08b (diff) | |
| download | cpython-3c30970d2910c6a6411bd8e1c0e2fe1bdfb99726.zip cpython-3c30970d2910c6a6411bd8e1c0e2fe1bdfb99726.tar.gz cpython-3c30970d2910c6a6411bd8e1c0e2fe1bdfb99726.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/test_zlib.py')
| -rw-r--r-- | Lib/test/test_zlib.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index eed8164..f3dffd6 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -396,6 +396,18 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase): y += dco.flush() self.assertEqual(y, 'foo') + 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 = 'abcdefghijklmnopqrstuvwxyz' + input2 = '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 |
