mirror of
https://github.com/python/cpython.git
synced 2024-11-27 20:04:41 +08:00
Fix for SF bug [ #443866 ] Evaluating func_code causing core dump
If the code object has free variables, raise TypeError.
This commit is contained in:
parent
e3c37d660f
commit
15c1c4f6d2
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user