Commit a3070d53 authored by Benjamin Peterson's avatar Benjamin Peterson Committed by GitHub

bpo-31347: _PyObject_FastCall_Prepend: do not call memcpy if args might not be null (#3329)

Passing NULL as the second argument to to memcpy is undefined behavior even if the size is 0.
parent db564238
Fix possible undefined behavior in _PyObject_FastCall_Prepend.
......@@ -854,9 +854,9 @@ _PyObject_FastCall_Prepend(PyObject *callable,
/* use borrowed references */
args2[0] = obj;
memcpy(&args2[1],
args,
(nargs - 1)* sizeof(PyObject *));
if (nargs > 1) {
memcpy(&args2[1], args, (nargs - 1) * sizeof(PyObject *));
}
result = _PyObject_FastCall(callable, args2, nargs);
if (args2 != small_stack) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment