]> granicus.if.org Git - python/commitdiff
Closes #15737: Fix potential NULL dereference in zipimport.c.
authorStefan Krah <skrah@bytereef.org>
Mon, 20 Aug 2012 12:14:49 +0000 (14:14 +0200)
committerStefan Krah <skrah@bytereef.org>
Mon, 20 Aug 2012 12:14:49 +0000 (14:14 +0200)
Modules/zipimport.c

index ac8dd0961545077fb28c9e72b86108baff53a538..12bfe233fc57c79364400f6635b38e3abdc8bc12 100644 (file)
@@ -947,8 +947,6 @@ read_directory(PyObject *archive)
         else
             charset = "cp437";
         nameobj = PyUnicode_Decode(name, name_size, charset, NULL);
-        if (PyUnicode_READY(nameobj) == -1)
-            goto error;
         if (nameobj == NULL) {
             if (bootstrap)
                 PyErr_Format(PyExc_NotImplementedError,
@@ -957,6 +955,8 @@ read_directory(PyObject *archive)
                     PY_MAJOR_VERSION, PY_MINOR_VERSION);
             goto error;
         }
+        if (PyUnicode_READY(nameobj) == -1)
+            goto error;
         path = PyUnicode_FromFormat("%U%c%U", archive, SEP, nameobj);
         if (path == NULL)
             goto error;