summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-07-30 21:50:55 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-07-30 21:50:55 (GMT)
commit15c1c4f6d2cc9c657ae1cb3fc50b14d7e8063343 (patch)
tree596558a49a72666e72c6607ce55cd69e58583b7f
parente3c37d660f5641f55c12313fde8e20f8178d942a (diff)
downloadcpython-15c1c4f6d2cc9c657ae1cb3fc50b14d7e8063343.zip
cpython-15c1c4f6d2cc9c657ae1cb3fc50b14d7e8063343.tar.gz
cpython-15c1c4f6d2cc9c657ae1cb3fc50b14d7e8063343.tar.bz2
Fix for SF bug [ #443866 ] Evaluating func_code causing core dump
If the code object has free variables, raise TypeError.
-rw-r--r--Python/bltinmodule.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 6eb6aca..362cdaa 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -800,8 +800,14 @@ builtin_eval(PyObject *self, PyObject *args)
PyEval_GetBuiltins()) != 0)
return NULL;
}
- if (PyCode_Check(cmd))
+ if (PyCode_Check(cmd)) {
+ if (PyTuple_GET_SIZE(((PyCodeObject *)cmd)->co_freevars) > 0) {
+ PyErr_SetString(PyExc_TypeError,
+ "code object passed to eval() may not contain free variables");
+ return NULL;
+ }
return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
+ }
if (!PyString_Check(cmd) &&
!PyUnicode_Check(cmd)) {
PyErr_SetString(PyExc_TypeError,