Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Only dealloc should free memory
  • Loading branch information
Erlend E. Aasland committed May 12, 2021
commit fe74fc2dd9ca1a59e3f12a0bb5adaf0c36834b85
14 changes: 7 additions & 7 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,10 @@ Reader_dealloc(ReaderObj *self)
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
tp->tp_clear((PyObject *)self);
if (self->field != NULL) {
PyMem_Free(self->field);
self->field = NULL;
}
PyObject_GC_Del(self);
Py_DECREF(tp);
}
Expand All @@ -917,10 +921,6 @@ Reader_clear(ReaderObj *self)
Py_CLEAR(self->dialect);
Py_CLEAR(self->input_iter);
Py_CLEAR(self->fields);
if (self->field != NULL) {
PyMem_Free(self->field);
self->field = NULL;
}
return 0;
}

Expand Down Expand Up @@ -1346,9 +1346,6 @@ Writer_clear(WriterObj *self)
Py_CLEAR(self->dialect);
Py_CLEAR(self->write);
Py_CLEAR(self->error_obj);
if (self->rec != NULL) {
PyMem_Free(self->rec);
}
return 0;
}

Expand All @@ -1358,6 +1355,9 @@ Writer_dealloc(WriterObj *self)
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
tp->tp_clear((PyObject *)self);
if (self->rec != NULL) {
PyMem_Free(self->rec);
}
PyObject_GC_Del(self);
Py_DECREF(tp);
}
Expand Down