gh-155376: prevent supercheck NULL dereference - #155379
Open
BHUVANSH855 wants to merge 3 commits into
Open
Conversation
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.
Summary
Fix a NULL dereference in
supercheck()when an uninitializedsuperobject is used as a descriptor.What happened?
super.__new__(super)can create asuperobject whose internaltypefield isNULL. When that object is subsequently used through__get__(),supercheck()receives the NULL type pointer.The error-handling path in
supercheck()eventually formats an error message usingtype->tp_name, causing a NULL pointer dereference and a segmentation fault.Fix
This change:
typeinsupercheck().TypeError("super object has no type")instead of dereferencing the NULL pointer.tp_alloc()directly insuper_descr_get()for the internalsuperobject allocation.supercase.Reproducer
Before this change:
resulted in:
After this change:
Tests
Closes issue gh-155376