Skip to content

Commit

Permalink
GH-96678: Fix undefined behavior in ceval.c (#96708)
Browse files Browse the repository at this point in the history
  • Loading branch information
markshannon authored Sep 10, 2022
1 parent 72b29b2 commit 50a70a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix case of undefined behavior in ceval.c
8 changes: 7 additions & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 50a70a0

Please sign in to comment.