mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
+ if USE_STACKCHECK is defined, use PyOS_CheckStack to look
for excessive recursion.
This commit is contained in:
parent
aa39a7edf7
commit
18c2aa25a1
1 changed files with 7 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue