diff options
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r-- | Objects/classobject.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index ffd3f87..2415ed1 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -71,7 +71,11 @@ method_vectorcall(PyObject *method, PyObject *const *args, } /* use borrowed references */ newargs[0] = self; - memcpy(newargs + 1, args, totalargs * sizeof(PyObject *)); + if (totalargs) { /* bpo-37138: if totalargs == 0, then args may be + * NULL and calling memcpy() with a NULL pointer + * is undefined behaviour. */ + memcpy(newargs + 1, args, totalargs * sizeof(PyObject *)); + } result = _PyObject_Vectorcall(func, newargs, nargs+1, kwnames); PyMem_Free(newargs); } |