Skip to content

[mypyc] Fix refleak in str index#21251

Merged
hauntsaninja merged 2 commits intopython:masterfrom
hauntsaninja:mypycstrindex
Apr 16, 2026
Merged

[mypyc] Fix refleak in str index#21251
hauntsaninja merged 2 commits intopython:masterfrom
hauntsaninja:mypycstrindex

Conversation

@hauntsaninja
Copy link
Copy Markdown
Collaborator

Found by @devdanzin

Copy link
Copy Markdown
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Thanks, one minor comment.

Comment thread mypyc/lib-rt/str_ops.c Outdated
} else {
PyObject *index_obj = CPyTagged_AsObject(index);
return PyObject_GetItem(str, index_obj);
if (index_obj == NULL) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CPyTagged_AsObject never returns NULL (we abort() if we can't allocate a small object), so this is unncessary (but benign).

@hauntsaninja hauntsaninja merged commit 22610a2 into python:master Apr 16, 2026
17 checks passed
@hauntsaninja hauntsaninja deleted the mypycstrindex branch April 16, 2026 08:53
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