-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-38368: Added fix for ctypes crash when handling arrays in structs… #16589
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 1 commit
03934da
5c947c7
fd976d3
2b07ffe
4942f5c
b440691
8bc7ca9
f2f02a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -729,8 +729,8 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct | |
if (PyCArrayTypeObject_Check(desc)) { | ||
Py_ssize_t length = dict->length; | ||
StgDictObject *edict; | ||
ffi_type * dummy_struct; | ||
ffi_type ** dummy_fields; | ||
ffi_type *dummy_struct; | ||
ffi_type **dummy_fields; | ||
Py_ssize_t dummy_index; | ||
|
||
edict = PyType_stgdict(dict->proto); | ||
|
@@ -745,11 +745,13 @@ PyCStructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct | |
/* Do separate allocations for now. */ | ||
dummy_struct = PyMem_New(ffi_type, 1); | ||
if (dummy_struct == NULL) { | ||
Py_DECREF(pair); | ||
PyErr_NoMemory(); | ||
return -1; | ||
} | ||
dummy_fields = PyMem_New(ffi_type *, length + 1); | ||
if (dummy_fields == NULL) { | ||
Py_DECREF(pair); | ||
PyErr_NoMemory(); | ||
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. I think 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. Well, the problem is that we're doing these allocations in a loop, and unless we keep some sort of linked list or dynamically allocated structure to keep track of all our allocations (both 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. I will have a think about an alternative allocation strategy which allows an easier recovery, but it will be potentially a little harder to follow the logic compared to what's there now. |
||
return -1; | ||
} | ||
|
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.
I think there should be a
Py_DECREF(pair);
here.