diff options
author | Guido van Rossum <guido@python.org> | 1998-04-28 16:06:54 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-04-28 16:06:54 (GMT) |
commit | 9b00dfae752aa8f1e4c6d70469e50ec45fb057c3 (patch) | |
tree | 98c8135e7ff24d22fdc22b2254343f8de0fef235 | |
parent | f2044e1a71015843f5e07fb2b5faeb6228af96e1 (diff) | |
download | cpython-9b00dfae752aa8f1e4c6d70469e50ec45fb057c3.zip cpython-9b00dfae752aa8f1e4c6d70469e50ec45fb057c3.tar.gz cpython-9b00dfae752aa8f1e4c6d70469e50ec45fb057c3.tar.bz2 |
If USE_STACKCHECK is defined use PyOS_CheckStack() in the repr and str
routines. This catches a slightly different set of crashes than the
recursive-repr fix.
(Jack)
-rw-r--r-- | Objects/object.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c index 3289aba..0588fea 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -162,6 +162,12 @@ PyObject_Print(op, fp, flags) int ret = 0; if (PyErr_CheckSignals()) return -1; +#ifdef USE_STACKCHECK + if (PyOS_CheckStack()) { + PyErr_SetString(PyExc_MemoryError, "Stack overflow"); + return -1; + } +#endif if (op == NULL) { fprintf(fp, "<nil>"); } @@ -213,6 +219,12 @@ PyObject_Repr(v) { if (PyErr_CheckSignals()) return NULL; +#ifdef USE_STACKCHECK + if (PyOS_CheckStack()) { + PyErr_SetString(PyExc_MemoryError, "Stack overflow"); + return NULL; + } +#endif if (v == NULL) return PyString_FromString("<NULL>"); else if (v->ob_type->tp_repr == NULL) { |