mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-37138: fix undefined behaviour with memcpy() on NULL array (GH-13867)
(cherry picked from commit 1f9531764c
)
Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be>
This commit is contained in:
parent
84d47bd8ad
commit
6e053079ac
1 changed files with 5 additions and 1 deletions
|
@ -71,7 +71,11 @@ method_vectorcall(PyObject *method, PyObject *const *args,
|
|||
}
|
||||
/* use borrowed references */
|
||||
newargs[0] = self;
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue