Skip to content

Commit b9d89ad

Browse files
committed
Fix undefined behavior in ceval.c
1 parent b9634ac commit b9d89ad

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix case of undefined behavior in ceval.c

Python/ceval.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5535,7 +5535,13 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
55355535
/* Pack other positional arguments into the *args argument */
55365536
if (co->co_flags & CO_VARARGS) {
55375537
PyObject *u = NULL;
5538-
u = _PyTuple_FromArraySteal(args + n, argcount - n);
5538+
if (argcount == n) {
5539+
u = Py_NewRef(&_Py_SINGLETON(tuple_empty));
5540+
}
5541+
else {
5542+
assert(args != NULL);
5543+
u = _PyTuple_FromArraySteal(args + n, argcount - n);
5544+
}
55395545
if (u == NULL) {
55405546
goto fail_post_positional;
55415547
}

0 commit comments

Comments
 (0)