diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-06-07 18:25:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-07 18:25:53 (GMT) |
commit | 6e053079ac3fe50ffbe9128bcf766298168c31cb (patch) | |
tree | 0a99b60c04009e922efba7edd4348c75cca1b84b /Objects | |
parent | 84d47bd8ad48f29ed5d333f4307408ad1e081f59 (diff) | |
download | cpython-6e053079ac3fe50ffbe9128bcf766298168c31cb.zip cpython-6e053079ac3fe50ffbe9128bcf766298168c31cb.tar.gz cpython-6e053079ac3fe50ffbe9128bcf766298168c31cb.tar.bz2 |
bpo-37138: fix undefined behaviour with memcpy() on NULL array (GH-13867)
(cherry picked from commit 1f9531764cc0f8dbca1d8f429d162dc28282f4b4)
Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>
Diffstat (limited to 'Objects')
-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); } |