summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2000-08-07 17:33:38 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2000-08-07 17:33:38 (GMT)
commit18c2aa25a129fb6e38696b2b0fcabbb5af003a34 (patch)
tree0ee5d697a3cd9332461bfd1752ac409301ed1c85 /Modules
parentaa39a7edf704da9c3107456809a8b8b7b6619daa (diff)
downloadcpython-18c2aa25a129fb6e38696b2b0fcabbb5af003a34.zip
cpython-18c2aa25a129fb6e38696b2b0fcabbb5af003a34.tar.gz
cpython-18c2aa25a129fb6e38696b2b0fcabbb5af003a34.tar.bz2
+ if USE_STACKCHECK is defined, use PyOS_CheckStack to look
for excessive recursion.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_sre.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_sre.c b/Modules/_sre.c
index d3841d5..8add74e 100644
--- a/Modules/_sre.c
+++ b/Modules/_sre.c
@@ -58,7 +58,9 @@ char copyright[] = " SRE 0.9.8 Copyright (c) 1997-2000 by Secret Labs AB ";
/* optional features */
/* prevent run-away recursion (bad patterns on long strings) */
+#if !defined(USE_STACKCHECK)
#define USE_RECURSION_LIMIT 10000
+#endif
/* enables fast searching */
#define USE_FAST_SEARCH
@@ -527,6 +529,11 @@ SRE_MATCH(SRE_STATE* state, SRE_CODE* pattern, int level)
TRACE(("%8d: enter %d\n", PTR(ptr), level));
+#if defined(USE_STACKCHECK)
+ if (level % 10 == 0 && PyOS_CheckStack()) {
+ return SRE_ERROR_RECURSION_LIMIT;
+#endif
+
#if defined(USE_RECURSION_LIMIT)
if (level > USE_RECURSION_LIMIT)
return SRE_ERROR_RECURSION_LIMIT;