New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ctypes: Crash if manually-created CField instance is used #78878
Comments
It is possible to manually create an instance of private CField type which is used by ctypes to represent fields of Structure and Union types. This instance will be uninitialized because it's normally initialized when instances of Structure/Union are created, so calling its methods may crash the interpreter: from ctypes import *
class S(Structure):
_fields_ = [('x', c_int)]
CField = type(S.x)
f = CField()
repr(f) # Crash here Is this issue worth fixing? If so, is the correct way to set tp_new slot to NULL and fix the internal callers so that users wouldn't be able to create CField instances? |
Definitely yes.
I think yes. Do you mind to create a PR? |
I have try to cancel this PyCField_new function, but i am not sure I haven't break the code structure. |
ping |
…d` (pythonGH-14837) (cherry picked from commit d713c54) Co-authored-by: Hai Shi <shihai1992@gmail.com>
izbyshev mannequin commentedSep 15, 2018
•
edited by bedevere-bot
_ctypes.CField
#14837Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
_ctypes.CField
(GH-14837) #100413The text was updated successfully, but these errors were encountered: