GH-96678: Fix undefined behavior in ceval.c (#96708)

This commit is contained in:
Mark Shannon 2022-09-10 01:12:06 +01:00 committed by GitHub
parent 72b29b2611
commit 50a70a083d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1 @@
Fix case of undefined behavior in ceval.c

View file

@ -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;
}