diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-10-29 00:46:24 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-10-29 00:46:24 (GMT) |
commit | af8b7e823360f94714f8eded4a27572914851c7d (patch) | |
tree | f30429aa12ed95cca159f1ec51db543967634faf | |
parent | 73660af6afdd8309c85d5e513e319b7f0a5b006e (diff) | |
download | cpython-af8b7e823360f94714f8eded4a27572914851c7d.zip cpython-af8b7e823360f94714f8eded4a27572914851c7d.tar.gz cpython-af8b7e823360f94714f8eded4a27572914851c7d.tar.bz2 |
Issue #18408: Fix zipimport, handle PyUnicode_Substring() and get_subname() failures
-rw-r--r-- | Modules/zipimport.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 46b86a0..dceca5e 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -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); |