From 1b5c76a2832e3fc3eb4d850b5bc69692bf23c83a Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 10 Sep 2012 02:00:34 +0200 Subject: Fixed two memory leaks in make_filename() in zipimport.c. The allocated buffer wasn't cleaned up in two error cases. CID 486832 --- Modules/zipimport.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 12bfe23..ccbc784 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -236,12 +236,16 @@ make_filename(PyObject *prefix, PyObject *name) return NULL; } - if (!PyUnicode_AsUCS4(prefix, p, len, 0)) + if (!PyUnicode_AsUCS4(prefix, p, len, 0)) { + PyMem_Free(buf); return NULL; + } p += PyUnicode_GET_LENGTH(prefix); len -= PyUnicode_GET_LENGTH(prefix); - if (!PyUnicode_AsUCS4(name, p, len, 1)) + if (!PyUnicode_AsUCS4(name, p, len, 1)) { + PyMem_Free(buf); return NULL; + } for (; *p; p++) { if (*p == '.') *p = SEP; -- cgit v0.12