summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2023-02-23 14:00:58 (GMT)
committerGitHub <noreply@github.com>2023-02-23 14:00:58 (GMT)
commit665730d2176aabd05ca5741056aef43189b6f754 (patch)
treea91cd6c443b91d26f5f404629e265aefec8832c1 /Lib
parent9bba8035bd99813203cb3b0de218f9cc3bcdaf2f (diff)
downloadcpython-665730d2176aabd05ca5741056aef43189b6f754.zip
cpython-665730d2176aabd05ca5741056aef43189b6f754.tar.gz
cpython-665730d2176aabd05ca5741056aef43189b6f754.tar.bz2
bpo-23224: Fix segfaults and multiple leaks in the lzma and bz2 modules (GH-7822)
lzma.LZMADecompressor and bz2.BZ2Decompressor objects caused segfaults when their `__init__()` methods were not called. lzma.LZMADecompressor, lzma.LZMACompressor, bz2.BZ2Compressor, and bz2.BZ2Decompressor objects would leak locks and internal buffers when their `__init__()` methods were called multiple times. https://bugs.python.org/issue23224
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_bz2.py4
-rw-r--r--Lib/test/test_lzma.py4
2 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index c97ed1c..e4dd7fc 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -844,6 +844,10 @@ class BZ2DecompressorTest(BaseTest):
bzd.__init__()
self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
+ def test_uninitialized_BZ2Decompressor_crash(self):
+ self.assertEqual(BZ2Decompressor.__new__(BZ2Decompressor).
+ decompress(bytes()), b'')
+
class CompressDecompressTest(BaseTest):
def testCompress(self):
diff --git a/Lib/test/test_lzma.py b/Lib/test/test_lzma.py
index 18f474b..ac53bdd 100644
--- a/Lib/test/test_lzma.py
+++ b/Lib/test/test_lzma.py
@@ -380,6 +380,10 @@ class CompressorDecompressorTestCase(unittest.TestCase):
lzd.__init__()
self.assertAlmostEqual(gettotalrefcount() - refs_before, 0, delta=10)
+ def test_uninitialized_LZMADecompressor_crash(self):
+ self.assertEqual(LZMADecompressor.__new__(LZMADecompressor).
+ decompress(bytes()), b'')
+
class CompressDecompressFunctionTestCase(unittest.TestCase):