diff options
| author | Neal Norwitz <nnorwitz@gmail.com> | 2003-06-29 14:57:10 (GMT) |
|---|---|---|
| committer | Neal Norwitz <nnorwitz@gmail.com> | 2003-06-29 14:57:10 (GMT) |
| commit | b1c0258a165b0cc4ad62f4897ee2e4281fd2dffd (patch) | |
| tree | cb5e1afe84e5a856910a9b125b33c672b08f357e /Python | |
| parent | 6697232456892fe51d6831647480a41efa43a95a (diff) | |
| download | cpython-b1c0258a165b0cc4ad62f4897ee2e4281fd2dffd.zip cpython-b1c0258a165b0cc4ad62f4897ee2e4281fd2dffd.tar.gz cpython-b1c0258a165b0cc4ad62f4897ee2e4281fd2dffd.tar.bz2 | |
Backport:
Fix SF #762455, segfault when sys.stdout is changed in getattr
Note: in 2.2, the problem was an infinite loop (at least for me).
Diffstat (limited to 'Python')
| -rw-r--r-- | Python/ceval.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index d764b54..e8c14f8 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1365,6 +1365,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, 1)) err = PyFile_WriteString(" ", w); if (err == 0) @@ -1390,6 +1395,7 @@ eval_frame(PyFrameObject *f) } #endif } + Py_XDECREF(w); Py_DECREF(v); Py_XDECREF(stream); stream = NULL; |
