Mercurial > cpython-lru_cache-weakref
diff Python/symtable.c @ 85804:9a7ec433bf59
merge 3.3 (#19098)
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Thu, 26 Sep 2013 22:21:41 -0400 |
| parents | df2fdd42b375 c3df31cbcd0a |
| children |
line wrap: on
line diff
--- a/Python/symtable.c Thu Sep 26 09:35:39 2013 -0700 +++ b/Python/symtable.c Thu Sep 26 22:21:41 2013 -0400 @@ -239,6 +239,7 @@ asdl_seq *seq; int i; PyThreadState *tstate; + int recursion_limit = Py_GetRecursionLimit(); if (st == NULL) return NULL; @@ -256,8 +257,11 @@ 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) ||
