Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 39466:c7ff02c1559f legacy-trunk
Move/copy assert for tstate != NULL before first use.
Verify that PyEval_Get{Globals,Locals} returned valid pointers.
Klocwork 231-232
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Sun, 13 Aug 2006 18:10:10 +0000 |
| parents | 6cafdc81cfde |
| children | e2e80a016945 |
line wrap: on
line diff
--- a/Python/ceval.c Sun Aug 13 00:20:49 2006 +0000 +++ b/Python/ceval.c Sun Aug 13 18:10:10 2006 +0000 @@ -2623,6 +2623,7 @@ return NULL; } + assert(tstate != NULL); assert(globals != NULL); f = PyFrame_New(tstate, co, globals, locals); if (f == NULL) @@ -3636,6 +3637,7 @@ 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; @@ -3648,7 +3650,6 @@ fastlocals[i] = *stack++; } retval = PyEval_EvalFrameEx(f,0); - assert(tstate != NULL); ++tstate->recursion_depth; Py_DECREF(f); --tstate->recursion_depth; @@ -4130,6 +4131,11 @@ 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;
