[Zope3-checkins] CVS: Zope3/src/pythonlib/compat22 - _csv.c:1.3
Fred L. Drake, Jr.
fred at zope.com
Tue Sep 2 12:57:15 EDT 2003
Update of /cvs-repository/Zope3/src/pythonlib/compat22
In directory cvs.zope.org:/tmp/cvs-serv769
Modified Files:
_csv.c
Log Message:
update to match revision 1.12 from Python's CVS: adds fix for
potential memory leaks
=== Zope3/src/pythonlib/compat22/_csv.c 1.2 => 1.3 ===
--- Zope3/src/pythonlib/compat22/_csv.c:1.2 Wed Jun 11 05:13:14 2003
+++ Zope3/src/pythonlib/compat22/_csv.c Tue Sep 2 11:57:14 2003
@@ -442,7 +442,7 @@
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)dialect_init, /* tp_init */
- 0, /*PyType_GenericAlloc,*/ /* tp_alloc */
+ PyType_GenericAlloc, /* tp_alloc */
dialect_new, /* tp_new */
0, /* tp_free */
};
@@ -465,6 +465,8 @@
{
if (self->field_size == 0) {
self->field_size = 4096;
+ if (self->field != NULL)
+ PyMem_Free(self->field);
self->field = PyMem_Malloc(self->field_size);
}
else {
@@ -739,6 +741,8 @@
Py_XDECREF(self->dialect);
Py_XDECREF(self->input_iter);
Py_XDECREF(self->fields);
+ if (self->field != NULL)
+ PyMem_Free(self->field);
PyObject_GC_Del(self);
}
@@ -1002,6 +1006,8 @@
if (rec_len > self->rec_size) {
if (self->rec_size == 0) {
self->rec_size = (rec_len / MEM_INCR + 1) * MEM_INCR;
+ if (self->rec != NULL)
+ PyMem_Free(self->rec);
self->rec = PyMem_Malloc(self->rec_size);
}
else {
@@ -1191,6 +1197,8 @@
{
Py_XDECREF(self->dialect);
Py_XDECREF(self->writeline);
+ if (self->rec != NULL)
+ PyMem_Free(self->rec);
PyObject_GC_Del(self);
}
@@ -1504,9 +1512,6 @@
if (PyType_Ready(&Dialect_Type) < 0)
return;
-
-
- Dialect_Type.tp_alloc = PyType_GenericAlloc;
if (PyType_Ready(&Reader_Type) < 0)
return;
More information about the Zope3-Checkins
mailing list