summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-09-10 00:12:06 (GMT)
committerGitHub <noreply@github.com>2022-09-10 00:12:06 (GMT)
commit50a70a083d34305a52fac4f5901bff2ead152d68 (patch)
tree0284a73dc74d2d7fc11bed109a9177950d72f38b /Python/ceval.c
parent72b29b2611eb7d161958c92993c5050a037d06e4 (diff)
downloadcpython-50a70a083d34305a52fac4f5901bff2ead152d68.zip
cpython-50a70a083d34305a52fac4f5901bff2ead152d68.tar.gz
cpython-50a70a083d34305a52fac4f5901bff2ead152d68.tar.bz2
GH-96678: Fix undefined behavior in ceval.c (#96708)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 7d4543e..20d0e1c 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -5532,7 +5532,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;
}