mirror of
https://github.com/python/cpython
synced 2026-09-29 11:10:30 +03:00
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.
This commit is contained in:
parent
db564238db
commit
a3070d530c
2 changed files with 4 additions and 3 deletions
|
|
@ -0,0 +1 @@
|
|||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue