[Python-checkins] cpython: Fixed two memory leaks in make_filename() in zipimport.c. The allocated buffer

christian.heimes python-checkins at python.org
Mon Sep 10 02:00:43 CEST 2012


http://hg.python.org/cpython/rev/6bd9626b0cc6
changeset:   78933:6bd9626b0cc6
user:        Christian Heimes <christian at cheimes.de>
date:        Mon Sep 10 02:00:34 2012 +0200
summary:
  Fixed two memory leaks in make_filename() in zipimport.c. The allocated buffer wasn't cleaned up in two error cases. CID 486832

files:
  Modules/zipimport.c |  8 ++++++--
  1 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Modules/zipimport.c b/Modules/zipimport.c
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -236,12 +236,16 @@
         return NULL;
     }
 
-    if (!PyUnicode_AsUCS4(prefix, p, len, 0))
+    if (!PyUnicode_AsUCS4(prefix, p, len, 0)) {
+        PyMem_Free(buf);
         return NULL;
+    }
     p += PyUnicode_GET_LENGTH(prefix);
     len -= PyUnicode_GET_LENGTH(prefix);
-    if (!PyUnicode_AsUCS4(name, p, len, 1))
+    if (!PyUnicode_AsUCS4(name, p, len, 1)) {
+        PyMem_Free(buf);
         return NULL;
+    }
     for (; *p; p++) {
         if (*p == '.')
             *p = SEP;

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


More information about the Python-checkins mailing list