Skip to content

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

Open
mjbommar wants to merge 1 commit intopython:mainfrom
mjbommar:gh-148651-zstd-decref-leak
Open

gh-148651: Fix Py_DECREF(value) leak in _zstd decompressor options#148657
mjbommar wants to merge 1 commit intopython:mainfrom
mjbommar:gh-148651-zstd-decref-leak

Conversation

@mjbommar
Copy link
Copy Markdown

@mjbommar mjbommar commented Apr 16, 2026

Fixes #148651 with DecRef proposed in the original report.

Modules/_zstd/decompressor.c line 113 is 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.

Confirmed with refcount test from the original report: before fix, 100 error triggers leak 100 refs; after fix, 0 leaked.

@mjbommar mjbommar force-pushed the gh-148651-zstd-decref-leak branch from 5b72ba3 to e45b490 Compare April 16, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Leak: _zstd.ZstdDecompressor() leaks a reference on invalid option key

1 participant