gh-148651: Fix refcount leak in _zstd decompressor options (#148657)

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.
This commit is contained in:
Michael Bommarito 2026-04-17 11:42:41 -04:00 committed by GitHub
parent a86234ea85
commit 446edda209
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 0 deletions

View file

@ -0,0 +1,2 @@
Fix reference leak in :class:`compression.zstd.ZstdDecompressor` when an
invalid option key is passed.

View 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;
}