Move/copy assert for tstate != NULL before first use.
Verify that PyEval_Get{Globals,Locals} returned valid pointers. Klocwork 231-232
This commit is contained in:
parent
bfa5f0bb5d
commit
df6a6494cb
|
@ -2623,6 +2623,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(tstate != NULL);
|
||||||
assert(globals != NULL);
|
assert(globals != NULL);
|
||||||
f = PyFrame_New(tstate, co, globals, locals);
|
f = PyFrame_New(tstate, co, globals, locals);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
|
@ -3636,6 +3637,7 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk)
|
||||||
PyFrame_New() that doesn't take locals, but does
|
PyFrame_New() that doesn't take locals, but does
|
||||||
take builtins without sanity checking them.
|
take builtins without sanity checking them.
|
||||||
*/
|
*/
|
||||||
|
assert(tstate != NULL);
|
||||||
f = PyFrame_New(tstate, co, globals, NULL);
|
f = PyFrame_New(tstate, co, globals, NULL);
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -3648,7 +3650,6 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk)
|
||||||
fastlocals[i] = *stack++;
|
fastlocals[i] = *stack++;
|
||||||
}
|
}
|
||||||
retval = PyEval_EvalFrameEx(f,0);
|
retval = PyEval_EvalFrameEx(f,0);
|
||||||
assert(tstate != NULL);
|
|
||||||
++tstate->recursion_depth;
|
++tstate->recursion_depth;
|
||||||
Py_DECREF(f);
|
Py_DECREF(f);
|
||||||
--tstate->recursion_depth;
|
--tstate->recursion_depth;
|
||||||
|
@ -4130,6 +4131,11 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
|
||||||
locals = PyEval_GetLocals();
|
locals = PyEval_GetLocals();
|
||||||
plain = 1;
|
plain = 1;
|
||||||
}
|
}
|
||||||
|
if (!globals || !locals) {
|
||||||
|
PyErr_SetString(PyExc_SystemError,
|
||||||
|
"globals and locals cannot be NULL");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (locals == Py_None)
|
else if (locals == Py_None)
|
||||||
locals = globals;
|
locals = globals;
|
||||||
|
|
Loading…
Reference in New Issue