summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-01-05 15:46:58 (GMT)
committerGitHub <noreply@github.com>2021-01-05 15:46:58 (GMT)
commit6e72ab909de58e89b5a7cd6899587e203cf129a3 (patch)
tree49a9596ae948de6836e434b8b885448fd82eb70e /Objects
parent9b3a53a8264d4c469a3f3d8c037e74c010be3e5c (diff)
downloadcpython-6e72ab909de58e89b5a7cd6899587e203cf129a3.zip
cpython-6e72ab909de58e89b5a7cd6899587e203cf129a3.tar.gz
cpython-6e72ab909de58e89b5a7cd6899587e203cf129a3.tar.bz2
[3.9] bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999) (GH-24005)
``` In file included from /usr/include/python3.8/Python.h:147: In file included from /usr/include/python3.8/abstract.h:837: /usr/include/python3.8/cpython/abstract.h:91:11: error: cast from 'char *' to 'vectorcallfunc *' (aka 'struct _object *(**)(struct _object *, struct _object *const *, unsigned long, struct _object *)') increases required alignment from 1 to 8 [-Werror,-Wcast-align] ptr = (vectorcallfunc*)(((char *)callable) + offset); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. ``` Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-Authored-By: Andreas Schneider <asn@cryptomilk.org> Co-Authored-By: Antoine Pitrou <antoine@python.org> (cherry picked from commit 056c08211b402b4dbc1530a9de9d00ad5309909f)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/call.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Objects/call.c b/Objects/call.c
index 61426c7..87dc0dbb 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -205,6 +205,7 @@ PyObject *
PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *kwargs)
{
PyThreadState *tstate = _PyThreadState_GET();
+ vectorcallfunc func;
/* get vectorcallfunc as in PyVectorcall_Function, but without
* the Py_TPFLAGS_HAVE_VECTORCALL check */
@@ -215,7 +216,7 @@ PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *kwargs)
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(tstate, PyExc_TypeError,
"'%.200s' object does not support vectorcall",