Mercurial > cpython-lru_cache-weakref
diff Modules/_struct.c @ 63298:29ab536cfef6
Issue #9422: Fix memory leak when re-initializing a struct.Struct object.
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Thu, 29 Jul 2010 21:41:59 +0000 |
| parents | 2683333755f3 |
| children | 8304bd765bcf |
line wrap: on
line diff
--- a/Modules/_struct.c Thu Jul 29 17:55:01 2010 +0000 +++ b/Modules/_struct.c Thu Jul 29 21:41:59 2010 +0000 @@ -1247,6 +1247,9 @@ 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;
