[Python-checkins] python/dist/src/Python ceval.c,2.301.4.8,2.301.4.9

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Sun, 29 Jun 2003 07:57:12 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv8561/Python

Modified Files:
      Tag: release22-maint
	ceval.c 
Log Message:
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).


Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.301.4.8
retrieving revision 2.301.4.9
diff -C2 -d -r2.301.4.8 -r2.301.4.9
*** ceval.c	7 Oct 2002 09:47:20 -0000	2.301.4.8
--- ceval.c	29 Jun 2003 14:57:10 -0000	2.301.4.9
***************
*** 1366,1369 ****
--- 1366,1374 ----
  				}
  			}
+ 			/* 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);
***************
*** 1391,1394 ****
--- 1396,1400 ----
  #endif
  			}
+ 			Py_XDECREF(w);
  			Py_DECREF(v);
  			Py_XDECREF(stream);