Skip to content

Commit c6ea897

Browse files
ZackerySpytzserhiy-storchaka
authored andcommitted
bpo-30640: Fix undefined behavior in _PyFunction_FastCallDict() and PyEval_EvalCodeEx() (#2919)
k + 1 was calculated with k = NULL.
1 parent a568e52 commit c6ea897

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Objects/call.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ _PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs,
374374

375375
result = _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL,
376376
args, nargs,
377-
k, k + 1, nk, 2,
377+
k, k != NULL ? k + 1 : NULL, nk, 2,
378378
d, nd, kwdefs,
379379
closure, name, qualname);
380380
Py_XDECREF(kwtuple);

Python/ceval.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4220,7 +4220,8 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
42204220
{
42214221
return _PyEval_EvalCodeWithName(_co, globals, locals,
42224222
args, argcount,
4223-
kws, kws + 1, kwcount, 2,
4223+
kws, kws != NULL ? kws + 1 : NULL,
4224+
kwcount, 2,
42244225
defs, defcount,
42254226
kwdefs, closure,
42264227
NULL, NULL);

0 commit comments

Comments
 (0)