From: Jeremy Hylton Date: Mon, 30 Jul 2001 21:50:55 +0000 (+0000) Subject: Fix for SF bug [ #443866 ] Evaluating func_code causing core dump X-Git-Tag: v2.2a3~923 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=15c1c4f6d2cc9c657ae1cb3fc50b14d7e8063343;p=thirdparty%2FPython%2Fcpython.git Fix for SF bug [ #443866 ] Evaluating func_code causing core dump If the code object has free variables, raise TypeError. --- diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 6eb6acae56f1..362cdaa2787d 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,