summaryrefslogtreecommitdiffstats
path: root/Modules/_struct.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-07-29 21:41:59 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-07-29 21:41:59 (GMT)
commitcf28b95800ce1480b88975270cc3a3d65dee4664 (patch)
treeb7ec9f4fd93794220e8349a261669d40e4cfef68 /Modules/_struct.c
parent0a0fc07d371a97c35a6fc7c5a9828af3930720a1 (diff)
downloadcpython-cf28b95800ce1480b88975270cc3a3d65dee4664.zip
cpython-cf28b95800ce1480b88975270cc3a3d65dee4664.tar.gz
cpython-cf28b95800ce1480b88975270cc3a3d65dee4664.tar.bz2
Issue #9422: Fix memory leak when re-initializing a struct.Struct object.
Diffstat (limited to 'Modules/_struct.c')
-rw-r--r--Modules/_struct.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c
index d55ce0f..f85d562 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -1247,6 +1247,9 @@ prepare_s(PyStructObject *self)
PyErr_NoMemory();
return -1;
}
+ /* Free any s_codes value left over from a previous initialization. */
+ if (self->s_codes != NULL)
+ PyMem_FREE(self->s_codes);
self->s_codes = codes;
s = fmt;