{
PyTypeObject *tp = Py_TYPE(callable);
Py_ssize_t offset = tp->tp_vectorcall_offset;
- vectorcallfunc *ptr;
+ vectorcallfunc ptr;
if (!PyType_HasFeature(tp, _Py_TPFLAGS_HAVE_VECTORCALL)) {
return NULL;
}
assert(PyCallable_Check(callable));
assert(offset > 0);
- ptr = (vectorcallfunc*)(((char *)callable) + offset);
- return *ptr;
+ memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
+ return ptr;
}
/* Call the callable object 'callable' with the "vectorcall" calling
{
/* get vectorcallfunc as in _PyVectorcall_Function, but without
* the _Py_TPFLAGS_HAVE_VECTORCALL check */
+ vectorcallfunc func;
Py_ssize_t offset = Py_TYPE(callable)->tp_vectorcall_offset;
if (offset <= 0) {
PyErr_Format(PyExc_TypeError, "'%.200s' object does not support vectorcall",
Py_TYPE(callable)->tp_name);
return NULL;
}
- vectorcallfunc func = *(vectorcallfunc *)(((char *)callable) + offset);
+ memcpy(&func, (char *) callable + offset, sizeof(func));
if (func == NULL) {
PyErr_Format(PyExc_TypeError, "'%.200s' object does not support vectorcall",
Py_TYPE(callable)->tp_name);