[Python-checkins] python/dist/src/Objects fileobject.c,2.189,2.190

aimacintyre at users.sourceforge.net aimacintyre at users.sourceforge.net
Sun Apr 4 01:58:30 EST 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30002

Modified Files:
	fileobject.c 
Log Message:
If a file is opened with an explicit buffer size >= 1, repeated
close() calls would attempt to free() the buffer already free()ed on
the first close().     [bug introduced with patch #788249]

Making sure that the buffer is free()ed in file object deallocation is 
a belt-n-braces bit of insurance against a memory leak.


Index: fileobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v
retrieving revision 2.189
retrieving revision 2.190
diff -C2 -d -r2.189 -r2.190
*** fileobject.c	21 Mar 2004 20:24:07 -0000	2.189
--- fileobject.c	4 Apr 2004 06:58:27 -0000	2.190
***************
*** 313,316 ****
--- 313,317 ----
  		Py_END_ALLOW_THREADS
  	}
+ 	PyMem_Free(f->f_setbuf);
  	Py_XDECREF(f->f_name);
  	Py_XDECREF(f->f_mode);
***************
*** 359,362 ****
--- 360,364 ----
  	}
  	PyMem_Free(f->f_setbuf);
+ 	f->f_setbuf = NULL;
  	if (sts == EOF)
  		return PyErr_SetFromErrno(PyExc_IOError);




More information about the Python-checkins mailing list