]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-148651: Fix refcount leak in _zstd decompressor options (#148657)
authorMichael Bommarito <michael.bommarito@gmail.com>
Fri, 17 Apr 2026 15:42:41 +0000 (11:42 -0400)
committerGitHub <noreply@github.com>
Fri, 17 Apr 2026 15:42:41 +0000 (08:42 -0700)
The option parsing in Modules/_zstd/decompressor.c had a missing Py_DECREF(value) before the early return -1 when PyLong_AsInt(key) fails. The identical code in Modules/_zstd/compressor.c line 158 has the fix.

Misc/NEWS.d/next/Library/2026-04-16-13-30-00.gh-issue-148651.ZsTdLk.rst [new file with mode: 0644]
Modules/_zstd/decompressor.c

diff --git a/Misc/NEWS.d/next/Library/2026-04-16-13-30-00.gh-issue-148651.ZsTdLk.rst b/Misc/NEWS.d/next/Library/2026-04-16-13-30-00.gh-issue-148651.ZsTdLk.rst
new file mode 100644 (file)
index 0000000..b69f94a
--- /dev/null
@@ -0,0 +1,2 @@
+Fix reference leak in :class:`compression.zstd.ZstdDecompressor` when an
+invalid option key is passed.
index 0186ee92f5b147844c9988131e71bdcb85a95cb0..46682b483ad06ab6b46b4e3da57eba02f6255a98 100644 (file)
@@ -111,6 +111,7 @@ _zstd_set_d_parameters(ZstdDecompressor *self, PyObject *options)
         int key_v = PyLong_AsInt(key);
         Py_DECREF(key);
         if (key_v == -1 && PyErr_Occurred()) {
+            Py_DECREF(value);
             return -1;
         }