diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-10-04 13:17:42 +0000 |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-10-04 13:17:42 +0000 |
commit | 3b93688db6abe8a1b3a975ad8a2e770af056c9aa (patch) | |
tree | cca81d30ee4ced6e04e415449c6f6625c4dae653 | |
parent | 3184f24de6b2b997f4ba951267f98a7cfc7cdc1b (diff) | |
download | cpython-git-3b93688db6abe8a1b3a975ad8a2e770af056c9aa.tar.gz |
[Backport r51245 | neal.norwitz]
Move/copy assert for tstate != NULL before first use.
Verify that PyEval_Get{Globals,Locals} returned valid pointers.
Klocwork 231-232
-rw-r--r-- | Python/ceval.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index d270c926e0..a6201b44ce 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2524,6 +2524,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, return NULL; } + assert(tstate != NULL); assert(globals != NULL); f = PyFrame_New(tstate, co, globals, locals); if (f == NULL) @@ -3631,6 +3632,7 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk) PyFrame_New() that doesn't take locals, but does take builtins without sanity checking them. */ + assert(tstate != NULL); f = PyFrame_New(tstate, co, globals, NULL); if (f == NULL) return NULL; @@ -3643,7 +3645,6 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk) fastlocals[i] = *stack++; } retval = PyEval_EvalFrame(f); - assert(tstate != NULL); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; @@ -4153,6 +4154,11 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals, locals = PyEval_GetLocals(); plain = 1; } + if (!globals || !locals) { + PyErr_SetString(PyExc_SystemError, + "globals and locals cannot be NULL"); + return -1; + } } else if (locals == Py_None) locals = globals; |