Repository navigation
Fix incorrect Py_DECREF call on stolen reference after PyList_SetItem failure - #19720
Merged
Merged
Conversation
Contributor
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
pllim
reviewed
May 9, 2026
mcara
reviewed
May 9, 2026
Comment on lines
+1
to
+3
| The issue occurs in multiple locations in `pyutil.c` and `wcslib_wrap.c`, where the error-handling block erroneously calls `Py_DECREF` on an item whose reference has already been stolen and decremented by the failed `PyList_SetItem` call. | ||
|
|
||
| Fixed a bug where a reference to an item is incorrectly decremented after a failed `PyList_SetItem` call, causing a potential use-after-free or double-decrement crash because `PyList_SetItem` always steals the reference even on failure. |
Contributor
There was a problem hiding this comment.
or like this:
Suggested change
| The issue occurs in multiple locations in `pyutil.c` and `wcslib_wrap.c`, where the error-handling block erroneously calls `Py_DECREF` on an item whose reference has already been stolen and decremented by the failed `PyList_SetItem` call. | |
| Fixed a bug where a reference to an item is incorrectly decremented after a failed `PyList_SetItem` call, causing a potential use-after-free or double-decrement crash because `PyList_SetItem` always steals the reference even on failure. | |
| Fix ``PyList_SetItem`` error paths to avoid use-after-free from decref of stolen references |
Co-authored-by: Mihai Cara <[email protected]>
Member
|
@mcara does this look good to you now? Thanks! |
mcara
approved these changes
May 11, 2026
mcara
left a comment
Contributor
There was a problem hiding this comment.
I thought I have already approved it - I was wrong. Thanks for the fix!
pllim
pushed a commit
that referenced
this pull request
May 11, 2026
…e after `PyList_SetItem` failure
pllim
added a commit
that referenced
this pull request
May 11, 2026
…e after `PyList_SetItem` failure (#19723) Co-authored-by: Wang Rui <[email protected]>
pllim
pushed a commit
that referenced
this pull request
May 11, 2026
…e after `PyList_SetItem` failure
pllim
added a commit
that referenced
this pull request
May 11, 2026
…e after `PyList_SetItem` failure (#19724) Co-authored-by: Wang Rui <[email protected]>
This was referenced May 18, 2026
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #19718