summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-06-29 14:48:32 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-06-29 14:48:32 (GMT)
commitc5131bc256dd26eb7d46ec5774a0a42915fac838 (patch)
tree25aa4cdf11d731dbe7f3c66303c33a5cb328cb02
parent478c10554b366989b341af4017602571edfe9b2e (diff)
downloadcpython-c5131bc256dd26eb7d46ec5774a0a42915fac838.zip
cpython-c5131bc256dd26eb7d46ec5774a0a42915fac838.tar.gz
cpython-c5131bc256dd26eb7d46ec5774a0a42915fac838.tar.bz2
Fix SF #762455, segfault when sys.stdout is changed in getattr
Will backport.
-rw-r--r--Python/ceval.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 07862d0..035520a 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1501,6 +1501,11 @@ eval_frame(PyFrameObject *f)
err = -1;
}
}
+ /* PyFile_SoftSpace() can exececute arbitrary code
+ if sys.stdout is an instance with a __getattr__.
+ If __getattr__ raises an exception, w will
+ be freed, so we need to prevent that temporarily. */
+ Py_XINCREF(w);
if (w != NULL && PyFile_SoftSpace(w, 0))
err = PyFile_WriteString(" ", w);
if (err == 0)
@@ -1528,6 +1533,7 @@ eval_frame(PyFrameObject *f)
else
PyFile_SoftSpace(w, 1);
}
+ Py_XDECREF(w);
Py_DECREF(v);
Py_XDECREF(stream);
stream = NULL;