[Python-checkins] cpython (merge 3.3 -> default): merge 3.3 (#19098)
benjamin.peterson
python-checkins at python.org
Fri Sep 27 04:22:15 CEST 2013
http://hg.python.org/cpython/rev/9a7ec433bf59
changeset: 85804:9a7ec433bf59
parent: 85802:c02f464dd721
parent: 85803:c3df31cbcd0a
user: Benjamin Peterson <benjamin at python.org>
date: Thu Sep 26 22:21:41 2013 -0400
summary:
merge 3.3 (#19098)
files:
Misc/NEWS | 3 +++
Python/symtable.c | 8 ++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -9,6 +9,9 @@
- Issue #18818: The "encodingname" part of PYTHONIOENCODING is now optional.
+- Issue #19098: Prevent overflow in the compiler when the recursion limit is set
+ absurbly high.
+
Library
-------
diff --git a/Python/symtable.c b/Python/symtable.c
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -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) ||
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list