Mercurial > cpython-lru_cache-weakref
diff Python/errors.c @ 73880:57de1ad15c54 2.7
Issue #13546: Fixed an overflow issue that could crash the intepreter when
calling sys.setrecursionlimit((1<<31)-1).
2.7 only.
| author | Amaury Forgeot d'Arc <amauryfa@gmail.com> |
|---|---|
| date | Wed, 07 Dec 2011 21:46:48 +0100 |
| parents | b36cb4602e21 |
| children |
line wrap: on
line diff
--- a/Python/errors.c Tue Dec 06 20:46:04 2011 +0100 +++ b/Python/errors.c Wed Dec 07 21:46:48 2011 +0100 @@ -111,9 +111,11 @@ PyErr_Fetch(&exception, &value, &tb); /* Temporarily bump the recursion limit, so that in the most common case PyObject_IsSubclass will not raise a recursion - error we have to ignore anyway. */ + error we have to ignore anyway. Don't do it when the limit + is already insanely high, to avoid overflow */ reclimit = Py_GetRecursionLimit(); - Py_SetRecursionLimit(reclimit + 5); + if (reclimit < (1 << 30)) + Py_SetRecursionLimit(reclimit + 5); res = PyObject_IsSubclass(err, exc); Py_SetRecursionLimit(reclimit); /* This function must not fail, so print the error here */
