[Python-checkins] cpython (3.3): Closes #20908: Memory leak in Reg2Py()

jesus.cea python-checkins at python.org
Thu Mar 13 17:38:41 CET 2014


http://hg.python.org/cpython/rev/07968254be96
changeset:   89637:07968254be96
branch:      3.3
parent:      89626:43b06352221b
user:        Jesus Cea <jcea at jcea.es>
date:        Thu Mar 13 17:35:32 2014 +0100
summary:
  Closes #20908: Memory leak in Reg2Py()

files:
  PC/winreg.c |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/PC/winreg.c b/PC/winreg.c
--- a/PC/winreg.c
+++ b/PC/winreg.c
@@ -943,8 +943,10 @@
 
                 fixupMultiSZ(str, data, len);
                 obData = PyList_New(s);
-                if (obData == NULL)
+                if (obData == NULL) {
+                    free(str);
                     return NULL;
+                }
                 for (index = 0; index < s; index++)
                 {
                     size_t len = wcslen(str[index]);
@@ -952,6 +954,7 @@
                         PyErr_SetString(PyExc_OverflowError,
                             "registry string is too long for a Python string");
                         Py_DECREF(obData);
+                        free(str);
                         return NULL;
                     }
                     PyList_SetItem(obData,

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list