diff options
author | Hood Chatham <roberthoodchatham@gmail.com> | 2022-04-14 14:27:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 14:27:01 (GMT) |
commit | 1b035d9699aaebbe4f1ca096345d538caa07907a (patch) | |
tree | 7c5104e6f30e44a499416f062d094eacc4a1ddb0 /Modules | |
parent | 17dbb6bc10ca8a8b602335414c047294f00afcbe (diff) | |
download | cpython-1b035d9699aaebbe4f1ca096345d538caa07907a.zip cpython-1b035d9699aaebbe4f1ca096345d538caa07907a.tar.gz cpython-1b035d9699aaebbe4f1ca096345d538caa07907a.tar.bz2 |
gh-91353: Fix void return type handling in ctypes (GH-32246)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/callbacks.c | 2 | ||||
-rw-r--r-- | Modules/_ctypes/callproc.c | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index bb59456..7dd1f99 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -399,7 +399,7 @@ CThunkObject *_ctypes_alloc_callback(PyObject *callable, #endif result = ffi_prep_cif(&p->cif, cc, Py_SAFE_DOWNCAST(nargs, Py_ssize_t, int), - _ctypes_get_ffi_type(restype), + p->ffi_restype, &p->atypes[0]); if (result != FFI_OK) { PyErr_Format(PyExc_RuntimeError, diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 4a6b8ec..720c4c0 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -1209,7 +1209,12 @@ PyObject *_ctypes_callproc(PPROC pProc, } } - rtype = _ctypes_get_ffi_type(restype); + if (restype == Py_None) { + rtype = &ffi_type_void; + } else { + rtype = _ctypes_get_ffi_type(restype); + } + resbuf = alloca(max(rtype->size, sizeof(ffi_arg))); #ifdef _Py_MEMORY_SANITIZER |