mirror of
https://github.com/python/cpython.git
synced 2025-12-10 11:00:14 +00:00
Issue #18408: Fix zipimport, handle PyUnicode_Substring() and get_subname() failures
This commit is contained in:
parent
73660af6af
commit
af8b7e8233
1 changed files with 7 additions and 2 deletions
|
|
@ -117,6 +117,8 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
|
||||||
if (flen == -1)
|
if (flen == -1)
|
||||||
break;
|
break;
|
||||||
filename = PyUnicode_Substring(path, 0, flen);
|
filename = PyUnicode_Substring(path, 0, flen);
|
||||||
|
if (filename == NULL)
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
if (filename == NULL) {
|
if (filename == NULL) {
|
||||||
PyErr_SetString(ZipImportError, "not a Zip file");
|
PyErr_SetString(ZipImportError, "not a Zip file");
|
||||||
|
|
@ -469,10 +471,13 @@ zipimporter_load_module(PyObject *obj, PyObject *args)
|
||||||
if (ispackage) {
|
if (ispackage) {
|
||||||
/* add __path__ to the module *before* the code gets
|
/* add __path__ to the module *before* the code gets
|
||||||
executed */
|
executed */
|
||||||
PyObject *pkgpath, *fullpath;
|
PyObject *pkgpath, *fullpath, *subname;
|
||||||
PyObject *subname = get_subname(fullname);
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
subname = get_subname(fullname);
|
||||||
|
if (subname == NULL)
|
||||||
|
goto error;
|
||||||
|
|
||||||
fullpath = PyUnicode_FromFormat("%U%c%U%U",
|
fullpath = PyUnicode_FromFormat("%U%c%U%U",
|
||||||
self->archive, SEP,
|
self->archive, SEP,
|
||||||
self->prefix, subname);
|
self->prefix, subname);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue