summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2006-10-17 19:30:48 (GMT)
committerThomas Heller <theller@ctypes.org>2006-10-17 19:30:48 (GMT)
commitd2ea4a258401dd97a5084398803ee8193f4f9c7a (patch)
treed50ed8d8d690616d05239f77eb6944de1cc79b1e /Modules
parentfefbc2029cf131cabb32fe4540fdbac12d40a271 (diff)
downloadcpython-d2ea4a258401dd97a5084398803ee8193f4f9c7a.zip
cpython-d2ea4a258401dd97a5084398803ee8193f4f9c7a.tar.gz
cpython-d2ea4a258401dd97a5084398803ee8193f4f9c7a.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/callbacks.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 41ec0f5..0e5d6c0 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -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;
}