]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix zipimport, handle PyUnicode_Substring() and get_subname() failures
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Oct 2013 00:46:24 +0000 (01:46 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 29 Oct 2013 00:46:24 +0000 (01:46 +0100)
Modules/zipimport.c

index 46b86a0cf4a9f2f21b1b3df47188cdcd1f59875e..dceca5e7cd4e3b286ba2db42cdb65573421129d2 100644 (file)
@@ -117,6 +117,8 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
         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 @@ zipimporter_load_module(PyObject *obj, PyObject *args)
     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);