diff options
author | Andrew McNamara <andrewm@object-craft.com.au> | 2003-06-09 05:59:23 (GMT) |
---|---|---|
committer | Andrew McNamara <andrewm@object-craft.com.au> | 2003-06-09 05:59:23 (GMT) |
commit | dcfb38c21b323d9672aee196fbec5276f30f512d (patch) | |
tree | dd1c1852dfa50be39a581fbc7d1e5e070e71f4c9 /Modules/_csv.c | |
parent | 9067c8d85c4774118675436208cadf59bb048552 (diff) | |
download | cpython-dcfb38c21b323d9672aee196fbec5276f30f512d.zip cpython-dcfb38c21b323d9672aee196fbec5276f30f512d.tar.gz cpython-dcfb38c21b323d9672aee196fbec5276f30f512d.tar.bz2 |
Fix potential leaks identified by Neal Norwitz.
Diffstat (limited to 'Modules/_csv.c')
-rw-r--r-- | Modules/_csv.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Modules/_csv.c b/Modules/_csv.c index ab9add2..89b0a0d 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -465,6 +465,8 @@ parse_grow_buff(ReaderObj *self) { 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 @@ Reader_dealloc(ReaderObj *self) 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 @@ join_check_rec_size(WriterObj *self, int rec_len) 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 @@ Writer_dealloc(WriterObj *self) { Py_XDECREF(self->dialect); Py_XDECREF(self->writeline); + if (self->rec != NULL) + PyMem_Free(self->rec); PyObject_GC_Del(self); } |