[Python-checkins] python/dist/src/Objects fileobject.c, 2.179.8.5, 2.179.8.6

aimacintyre at users.sourceforge.net aimacintyre at users.sourceforge.net
Sun Apr 4 03:06:16 EDT 2004


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

Modified Files:
      Tag: release23-maint
	fileobject.c 
Log Message:
Backport to 2.3:

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.179.8.5
retrieving revision 2.179.8.6
diff -C2 -d -r2.179.8.5 -r2.179.8.6
*** fileobject.c	19 Mar 2004 15:23:14 -0000	2.179.8.5
--- fileobject.c	4 Apr 2004 07:06:13 -0000	2.179.8.6
***************
*** 353,356 ****
--- 353,357 ----
  		Py_END_ALLOW_THREADS
  	}
+ 	PyMem_Free(f->f_setbuf);
  	Py_XDECREF(f->f_name);
  	Py_XDECREF(f->f_mode);
***************
*** 399,402 ****
--- 400,404 ----
  	}
  	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