From 000fde9651079209d5e4688c70099e326f2a57f9 Mon Sep 17 00:00:00 2001 From: Stefan Krah Date: Mon, 20 Aug 2012 14:14:49 +0200 Subject: [PATCH] Closes #15737: Fix potential NULL dereference in zipimport.c. --- Modules/zipimport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/zipimport.c b/Modules/zipimport.c index ac8dd096154..12bfe233fc5 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -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;