gh-148651: Fix refcount leak in _zstd decompressor options (GH-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.
(cherry picked from commit
446edda20919447fdc8b5a43f2f2ae686df82e6a)
Co-authored-by: Michael Bommarito <michael.bommarito@gmail.com>
--- /dev/null
+Fix reference leak in :class:`compression.zstd.ZstdDecompressor` when an
+invalid option key is passed.
int key_v = PyLong_AsInt(key);
Py_DECREF(key);
if (key_v == -1 && PyErr_Occurred()) {
+ Py_DECREF(value);
return -1;
}