mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00: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
1 changed files with 7 additions and 1 deletions
|
@ -800,8 +800,14 @@ builtin_eval(PyObject *self, PyObject *args)
|
||||||
PyEval_GetBuiltins()) != 0)
|
PyEval_GetBuiltins()) != 0)
|
||||||
return NULL;
|
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);
|
return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
|
||||||
|
}
|
||||||
if (!PyString_Check(cmd) &&
|
if (!PyString_Check(cmd) &&
|
||||||
!PyUnicode_Check(cmd)) {
|
!PyUnicode_Check(cmd)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue