gh-91353: Fix void return type handling in ctypes (GH-32246)

This commit is contained in:
Hood Chatham 2022-04-14 07:27:01 -07:00 • committed by GitHub
parent 17dbb6bc10
commit 1b035d9699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -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,

View file

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