]> granicus.if.org Git - python/commitdiff
Merged revisions 83239 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Thu, 29 Jul 2010 21:44:47 +0000 (21:44 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Thu, 29 Jul 2010 21:44:47 +0000 (21:44 +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 09cfe3c0c1345cf66cb83f9bdb3a59e391c96cdc..40b918b830193f2767b2ac48bc05b45c7a0088c4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -64,6 +64,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 f22c31cd2a021a482bfa148e83572f913a84e2ba..71e71dd0e239f4fb5e92a1cba3eaab67411d2b0d 100644 (file)
@@ -1289,6 +1289,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;