diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-09-10 13:58:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-10 13:58:45 (GMT) |
commit | 7033dc8adc10fcb7e8d2334e28dc8074a633917c (patch) | |
tree | 8b191bb168e053b153db483545e9730f6fa39f31 /Python | |
parent | c563b892618d1859ce0191c2e8097df4b3469f9a (diff) | |
download | cpython-7033dc8adc10fcb7e8d2334e28dc8074a633917c.zip cpython-7033dc8adc10fcb7e8d2334e28dc8074a633917c.tar.gz cpython-7033dc8adc10fcb7e8d2334e28dc8074a633917c.tar.bz2 |
GH-96678: Fix undefined behavior in ceval.c (GH-96708)
(cherry picked from commit 50a70a083d34305a52fac4f5901bff2ead152d68)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 461439b..66fa2ea 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -6166,7 +6166,13 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func, /* Pack other positional arguments into the *args argument */ if (co->co_flags & CO_VARARGS) { PyObject *u = NULL; - u = _PyTuple_FromArraySteal(args + n, argcount - n); + if (argcount == n) { + u = Py_NewRef(&_Py_SINGLETON(tuple_empty)); + } + else { + assert(args != NULL); + u = _PyTuple_FromArraySteal(args + n, argcount - n); + } if (u == NULL) { goto fail_post_positional; } |