From: Christian Heimes Date: Mon, 10 Sep 2012 00:00:34 +0000 (+0200) Subject: Fixed two memory leaks in make_filename() in zipimport.c. The allocated buffer wasn... X-Git-Tag: v3.3.1rc1~818^2^2~115 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1b5c76a2832e3fc3eb4d850b5bc69692bf23c83a;p=python Fixed two memory leaks in make_filename() in zipimport.c. The allocated buffer wasn't cleaned up in two error cases. CID 486832 --- diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 12bfe233fc..ccbc784658 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;