diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-12-07 20:46:48 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2011-12-07 20:46:48 (GMT) |
commit | 4bf21e28dfb42c2da3d440c2c0d9898cb3196fe1 (patch) | |
tree | b9fafb7a2350a27b2cf59a1ecfb84986601b65cd /Python | |
parent | a94b578431725ea50381e7d31ff5580741593398 (diff) | |
download | cpython-4bf21e28dfb42c2da3d440c2c0d9898cb3196fe1.zip cpython-4bf21e28dfb42c2da3d440c2c0d9898cb3196fe1.tar.gz cpython-4bf21e28dfb42c2da3d440c2c0d9898cb3196fe1.tar.bz2 |
Issue #13546: Fixed an overflow issue that could crash the intepreter when
calling sys.setrecursionlimit((1<<31)-1).
2.7 only.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/errors.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/errors.c b/Python/errors.c index 4294f2f..64ba05d 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -111,9 +111,11 @@ PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc) 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 */ |