-
-
Notifications
You must be signed in to change notification settings - Fork 34.9k
bpo-28129: Add NULL checks #403
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2016,6 +2016,11 @@ PyCSimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) | |
| return NULL; | ||
| } | ||
| sw_dict = PyType_stgdict(swapped); | ||
| if (sw_dict == NULL) { | ||
| Py_DECREF(result); | ||
| Py_DECREF(swapped); | ||
| return NULL; | ||
| } | ||
| #ifdef WORDS_BIGENDIAN | ||
| PyObject_SetAttrString((PyObject *)result, "__ctype_le__", swapped); | ||
| PyObject_SetAttrString((PyObject *)result, "__ctype_be__", (PyObject *)result); | ||
|
|
@@ -4054,6 +4059,8 @@ _init_pos_args(PyObject *self, PyTypeObject *type, | |
| } | ||
|
|
||
| dict = PyType_stgdict((PyObject *)type); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PyType_stgdict() never returns NULL here since _init_pos_args() is called only for _ctypes.Structure and _ctypes.Union which creates types with PyCStgDict or recursively for their base classes after checking that PyType_stgdict() is not NULL. |
||
| if (dict == NULL) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We've started to put curly braces around one-liners: https://www.python.org/dev/peps/pep-0007/#code-lay-out.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aaaaah, thanks for the confirmation @brettcannon ! I had a long discussion with @serhiy-storchaka about that ;-) |
||
| return -1; | ||
| fields = PyDict_GetItemString((PyObject *)dict, "_fields_"); | ||
| if (fields == NULL) | ||
| return index; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PyType_stgdict() never returns NULL here since CreateSwappedType() just created a type with PyCStgDict.