Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[3.8] bpo-40052: Fix alignment issue in PyVectorcall_Function() (GH-23999) #24120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Include/cpython/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ _PyVectorcall_Function(PyObject *callable)
{
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an alignment build warning/error in function ``PyVectorcall_Function()``.
Patch by Andreas Schneider, Antoine Pitrou and Petr Viktorin.
3 changes: 2 additions & 1 deletion Objects/call.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,14 @@ PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *kwargs)
{
/* 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);
Expand Down