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:
Thomas Heller 2006-10-17 19:30:48 +00:00
parent fefbc2029c
commit d2ea4a2584
3 changed files with 22 additions and 2 deletions

View file

@ -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;
}