]> granicus.if.org Git - python/commitdiff
Fixed two memory leaks in make_filename() in zipimport.c. The allocated buffer wasn...
authorChristian Heimes <christian@cheimes.de>
Mon, 10 Sep 2012 00:00:34 +0000 (02:00 +0200)
committerChristian Heimes <christian@cheimes.de>
Mon, 10 Sep 2012 00:00:34 +0000 (02:00 +0200)
Modules/zipimport.c

index 12bfe233fc57c79364400f6635b38e3abdc8bc12..ccbc78465831863d4d4d6b3aab9d1d1cdf5d8a69 100644 (file)
@@ -236,12 +236,16 @@ make_filename(PyObject *prefix, PyObject *name)
         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;