diff Python/ceval.c @ 39998:42abfb391300 2.4

[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
author Andrew M. Kuchling <amk@amk.ca>
date Wed, 04 Oct 2006 13:17:42 +0000
parents accfb156f9cc
children 9118ea781fd5
line wrap: on
line diff
--- a/Python/ceval.c	Wed Oct 04 13:14:48 2006 +0000
+++ b/Python/ceval.c	Wed Oct 04 13:17:42 2006 +0000
@@ -2524,6 +2524,7 @@
 		return NULL;
 	}
 
+	assert(tstate != NULL);
 	assert(globals != NULL);
 	f = PyFrame_New(tstate, co, globals, locals);
 	if (f == NULL)
@@ -3631,6 +3632,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;
@@ -3643,7 +3645,6 @@
 			fastlocals[i] = *stack++;
 		}
 		retval = PyEval_EvalFrame(f);
-		assert(tstate != NULL);
 		++tstate->recursion_depth;
 		Py_DECREF(f);
 		--tstate->recursion_depth;
@@ -4153,6 +4154,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;