]> granicus.if.org Git - python/commitdiff
Merged revisions 83239 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Thu, 29 Jul 2010 21:43:24 +0000 (21:43 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Thu, 29 Jul 2010 21:43:24 +0000 (21:43 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83239 | mark.dickinson | 2010-07-29 22:41:59 +0100 (Thu, 29 Jul 2010) | 2 lines

  Issue #9422:  Fix memory leak when re-initializing a struct.Struct object.
........

Misc/NEWS
Modules/_struct.c

index 833d0deef675908e5322811a1386d3dc2a90fd0f..95051913b6eebb315588bf302ba5b49c74fd49d2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -323,6 +323,8 @@ Library
 Extension Modules
 -----------------
 
+- Issue #9422: Fix memory leak when re-initializing a struct.Struct object.
+
 - Issue #7900: The getgroups(2) system call on MacOSX behaves rather oddly
   compared to other unix systems. In particular, os.getgroups() does
   not reflect any changes made using os.setgroups() but basicly always
index c1db286b051ee806fdfb7a918d9af1df0e75e3c0..74d846a42c09811d576c19bbaa5e1549e8896630 100644 (file)
@@ -1233,6 +1233,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;