Merged revisions 83241 via svnmerge from
authorMark Dickinson <dickinsm@gmail.com>
Thu, 29 Jul 2010 21:47:28 +0000 (21:47 +0000)
committerMark Dickinson <dickinsm@gmail.com>
Thu, 29 Jul 2010 21:47:28 +0000 (21:47 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint

................
  r83241 | mark.dickinson | 2010-07-29 22:44:47 +0100 (Thu, 29 Jul 2010) | 9 lines

  Merged revisions 83239 via svnmerge from
  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 5ce766435f925e1c2c1203feeaa26be250c2cb37..ad25699ecb3feb366110240d5d8072c67493d309 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -322,6 +322,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 936e8af043602cbe388dcbfd276c7f1e8575de11..b85d1063685f7ade7fff16f544979c8aa80d7017 100644 (file)
@@ -1404,6 +1404,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;