[Python-checkins] r52144 - python/branches/release24-maint/Python/ceval.c

andrew.kuchling python-checkins at python.org
Wed Oct 4 15:17:42 CEST 2006


Author: andrew.kuchling
Date: Wed Oct  4 15:17:42 2006
New Revision: 52144

Modified:
   python/branches/release24-maint/Python/ceval.c
Log:
[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



Modified: python/branches/release24-maint/Python/ceval.c
==============================================================================
--- python/branches/release24-maint/Python/ceval.c	(original)
+++ python/branches/release24-maint/Python/ceval.c	Wed Oct  4 15:17:42 2006
@@ -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;


More information about the Python-checkins mailing list