From 5a7913eb3bf390a2f3fd28116fc789bf2c7e4b64 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 16 Oct 2010 11:29:07 +0000 Subject: [PATCH] zipimport: catch _PyUnicode_AsString() failure in get_code_from_data() It occurs if the path contains surrogates. --- Modules/zipimport.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/zipimport.c b/Modules/zipimport.c index d1c939f984..efe69721dd 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -1119,6 +1119,10 @@ get_code_from_data(ZipImporter *self, int ispackage, int isbytecode, return NULL; modpath = _PyUnicode_AsString(PyTuple_GetItem(toc_entry, 0)); + if (modpath == NULL) { + Py_DECREF(data); + return NULL; + } if (isbytecode) { code = unmarshal_code(modpath, data, mtime); -- 2.40.0