Skip to content

Commit 446edda

Browse files
authored
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.
1 parent a86234e commit 446edda

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix reference leak in :class:`compression.zstd.ZstdDecompressor` when an
2+
invalid option key is passed.

Modules/_zstd/decompressor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ _zstd_set_d_parameters(ZstdDecompressor *self, PyObject *options)
111111
int key_v = PyLong_AsInt(key);
112112
Py_DECREF(key);
113113
if (key_v == -1 && PyErr_Occurred()) {
114+
Py_DECREF(value);
114115
return -1;
115116
}
116117

0 commit comments

Comments
 (0)