Skip to content

fix leak in typenode_collect_literal - #1021

Merged
jcrist merged 1 commit into
msgspec:mainfrom
provinzkraut:fix-typenode-collect-literal
Apr 13, 2026
Merged

jcrist merged 1 commit into
msgspec:mainfrom
provinzkraut:fix-typenode-collect-literal

Conversation

@provinzkraut

Copy link
Copy Markdown
Member

Fix leak caused by a missing Py_DECREF on an error path in typenode_collect_literal. Only possible on Python <3.12, as empty tuples are immortalized from 3.12 onwards.

@jcrist jcrist left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Just noting severity for anyone following along - this leak would only ever leak references to an empty tuple (an immortal singleton on all python versions, effectively leaking nothing). It also only shows up in the case of a Literal with no arguments, which is already a user-error.

Not saying we shouldn't fix it! Some people just associate leaks like this with major issues, and this one is very very minor.

@jcrist
jcrist merged commit 72cc647 into msgspec:main Apr 13, 2026
22 checks passed
@provinzkraut
provinzkraut deleted the fix-typenode-collect-literal branch April 13, 2026 19:17
@provinzkraut

Copy link
Copy Markdown
Member Author

Yeah, it's virtually impossible to hit, and completely irrelevant in 3.12+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants