diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2000-08-22 21:52:51 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2000-08-22 21:52:51 (GMT) |
commit | d49cbe10603c1b84a408c47f15131c44edad2f32 (patch) | |
tree | 784c017c4063adf148c50b9bdabb26cd373a6af6 | |
parent | e979160f5eedeaeb69b74e8ad20d6d9f141ad337 (diff) | |
download | cpython-d49cbe10603c1b84a408c47f15131c44edad2f32.zip cpython-d49cbe10603c1b84a408c47f15131c44edad2f32.tar.gz cpython-d49cbe10603c1b84a408c47f15131c44edad2f32.tar.bz2 |
Added PyOS_CheckStack call to PyObject_Compare
Lowered the recursion limit on compares to 60 (one recursion depth can
take a whopping 2K of stack space when running test_b1!)
-rw-r--r-- | Objects/object.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index f61a1dd..1f02aae 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -11,6 +11,9 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. /* Generic object operations; and implementation of None (NoObject) */ #include "Python.h" +#ifdef HAVE_LIMITS_H +#include <limits.h> +#endif #ifdef macintosh #include "macglue.h" @@ -339,7 +342,11 @@ PyObject *_PyCompareState_Key; some types) and decremented on exit. If the count exceeds the nesting limit, enable code to detect circular data structures. */ +#ifdef macintosh +#define NESTING_LIMIT 60 +#else #define NESTING_LIMIT 500 +#endif int _PyCompareState_nesting = 0; static PyObject* @@ -394,6 +401,12 @@ PyObject_Compare(PyObject *v, PyObject *w) PyTypeObject *vtp, *wtp; int result; +#if defined(USE_STACKCHECK) + if (PyOS_CheckStack() < 0) { + PyErr_SetString(PyExc_MemoryError, "Stack overflow"); + return -1; + } +#endif if (v == NULL || w == NULL) { PyErr_BadInternalCall(); return -1; |