--- /dev/null
+ctypes used to mishandle ``void`` return types, so that for instance a
+function declared like ``ctypes.CFUNCTYPE(None, ctypes.c_int)`` would be
+called with signature ``int f(int)`` instead of ``void f(int)``. Wasm
+targets require function pointers to be called with the correct signatures
+so this led to crashes. The problem is now fixed.
#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,
}
}
- 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