[Python-checkins] cpython: Issue #18408: Fix zipimport, handle PyUnicode_Substring() and get_subname()

victor.stinner python-checkins at python.org
Tue Oct 29 01:46:45 CET 2013


http://hg.python.org/cpython/rev/7f4a976829f1
changeset:   86718:7f4a976829f1
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Oct 29 01:46:24 2013 +0100
summary:
  Issue #18408: Fix zipimport, handle PyUnicode_Substring() and get_subname() failures

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


diff --git a/Modules/zipimport.c b/Modules/zipimport.c
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -117,6 +117,8 @@
         if (flen == -1)
             break;
         filename = PyUnicode_Substring(path, 0, flen);
+        if (filename == NULL)
+            goto error;
     }
     if (filename == NULL) {
         PyErr_SetString(ZipImportError, "not a Zip file");
@@ -469,10 +471,13 @@
     if (ispackage) {
         /* add __path__ to the module *before* the code gets
            executed */
-        PyObject *pkgpath, *fullpath;
-        PyObject *subname = get_subname(fullname);
+        PyObject *pkgpath, *fullpath, *subname;
         int err;
 
+        subname = get_subname(fullname);
+        if (subname == NULL)
+            goto error;
+
         fullpath = PyUnicode_FromFormat("%U%c%U%U",
                                 self->archive, SEP,
                                 self->prefix, subname);

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


More information about the Python-checkins mailing list