[Python-checkins] python/dist/src/Python ceval.c,2.366,2.367
nnorwitz@users.sourceforge.net
nnorwitz@users.sourceforge.net
2003年6月29日 07:48:34 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv7530/Python
Modified Files:
ceval.c
Log Message:
Fix SF #762455, segfault when sys.stdout is changed in getattr
Will backport.
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.366
retrieving revision 2.367
diff -C2 -d -r2.366 -r2.367
*** ceval.c 28 Jun 2003 21:53:52 -0000 2.366
--- ceval.c 29 Jun 2003 14:48:32 -0000 2.367
***************
*** 1502,1505 ****
--- 1502,1510 ----
}
}
+ /* 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);
***************
*** 1529,1532 ****
--- 1534,1538 ----
PyFile_SoftSpace(w, 1);
}
+ Py_XDECREF(w);
Py_DECREF(v);
Py_XDECREF(stream);