]> granicus.if.org Git - python/commitdiff
If USE_STACKCHECK is defined use PyOS_CheckStack() in the repr and str
authorGuido van Rossum <guido@python.org>
Tue, 28 Apr 1998 16:06:54 +0000 (16:06 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 28 Apr 1998 16:06:54 +0000 (16:06 +0000)
routines. This catches a slightly different set of crashes than the
recursive-repr fix.
(Jack)

Objects/object.c

index 3289aba4945c5c3352007440136573147b8b39d2..0588fea5061da0608166ff9daa98fb69125a8efb 100644 (file)
@@ -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) {