mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
ctypes callback functions only support 'fundamental' result types.
Check this and raise an error when something else is used - before this change ctypes would hang or crash when such a callback was called. This is a partial fix for #1574584. Will backport to release25-maint.
This commit is contained in:
parent
fefbc2029c
commit
d2ea4a2584
3 changed files with 22 additions and 2 deletions
|
@ -293,8 +293,11 @@ ffi_info *AllocFunctionCallback(PyObject *callable,
|
|||
p->restype = &ffi_type_void;
|
||||
} else {
|
||||
StgDictObject *dict = PyType_stgdict(restype);
|
||||
if (dict == NULL)
|
||||
goto error;
|
||||
if (dict == NULL || dict->setfunc == NULL) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"invalid result type for callback function");
|
||||
goto error;
|
||||
}
|
||||
p->setfunc = dict->setfunc;
|
||||
p->restype = &dict->ffi_type_pointer;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue