diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-09-27 02:21:41 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-09-27 02:21:41 (GMT) |
commit | c30d05855a0c617dd7d4a1cc2181c196aee8e3a5 (patch) | |
tree | 5b4f30066609af203b57a08b83c2e902abc43e6a /Python | |
parent | 1891cff587b348faea027e8836e5e6c30e19213c (diff) | |
parent | 305e5aac85d8350ef8501b5e53b91555b3d75b84 (diff) | |
download | cpython-c30d05855a0c617dd7d4a1cc2181c196aee8e3a5.zip cpython-c30d05855a0c617dd7d4a1cc2181c196aee8e3a5.tar.gz cpython-c30d05855a0c617dd7d4a1cc2181c196aee8e3a5.tar.bz2 |
merge 3.3 (#19098)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/symtable.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/symtable.c b/Python/symtable.c index 618a814..da164aa 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -239,6 +239,7 @@ PySymtable_BuildObject(mod_ty mod, PyObject *filename, PyFutureFeatures *future) asdl_seq *seq; int i; PyThreadState *tstate; + int recursion_limit = Py_GetRecursionLimit(); if (st == NULL) return NULL; @@ -256,8 +257,11 @@ PySymtable_BuildObject(mod_ty mod, PyObject *filename, PyFutureFeatures *future) PySymtable_Free(st); return NULL; } - st->recursion_depth = tstate->recursion_depth * COMPILER_STACK_FRAME_SCALE; - st->recursion_limit = Py_GetRecursionLimit() * COMPILER_STACK_FRAME_SCALE; + /* Be careful here to prevent overflow. */ + st->recursion_depth = (tstate->recursion_depth < INT_MAX / COMPILER_STACK_FRAME_SCALE) ? + tstate->recursion_depth * COMPILER_STACK_FRAME_SCALE : tstate->recursion_depth; + st->recursion_limit = (recursion_limit < INT_MAX / COMPILER_STACK_FRAME_SCALE) ? + recursion_limit * COMPILER_STACK_FRAME_SCALE : recursion_limit; /* Make the initial symbol information gathering pass */ if (!GET_IDENTIFIER(top) || |