[3.6] bpo-30640: Fix undefined behavior in _PyFunction_FastCallDict() and PyEval_EvalCodeEx() (GH-2919) (#2964)

k + 1 was calculated with k = NULL..
(cherry picked from commit c6ea8974e2)
This commit is contained in:
Zackery Spytz 2017-09-07 19:17:38 -06:00 committed by Victor Stinner
parent 645c1e4213
commit f032e9237a
1 changed files with 3 additions and 2 deletions

View File

@ -4171,7 +4171,8 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
{ {
return _PyEval_EvalCodeWithName(_co, globals, locals, return _PyEval_EvalCodeWithName(_co, globals, locals,
args, argcount, args, argcount,
kws, kws + 1, kwcount, 2, kws, kws != NULL ? kws + 1 : NULL,
kwcount, 2,
defs, defcount, defs, defcount,
kwdefs, closure, kwdefs, closure,
NULL, NULL); NULL, NULL);
@ -5053,7 +5054,7 @@ _PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs,
result = _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL, result = _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL,
args, nargs, args, nargs,
k, k + 1, nk, 2, k, k != NULL ? k + 1 : NULL, nk, 2,
d, nd, kwdefs, d, nd, kwdefs,
closure, name, qualname); closure, name, qualname);
Py_XDECREF(kwtuple); Py_XDECREF(kwtuple);