From: Stefan Krah Date: Sun, 19 Aug 2012 19:52:43 +0000 (+0200) Subject: Issue #15728: Fix leak in PyUnicode_AsWideCharString(). Found by Coverity. X-Git-Tag: v3.3.0rc1~72 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8528c3145e5856a88199f07e155b3c75710cc2a1;p=thirdparty%2FPython%2Fcpython.git Issue #15728: Fix leak in PyUnicode_AsWideCharString(). Found by Coverity. --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index d369861b3253..773a9be5cc34 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2935,8 +2935,10 @@ PyUnicode_AsWideCharString(PyObject *unicode, return NULL; } buflen = unicode_aswidechar(unicode, buffer, buflen); - if (buflen == -1) + if (buflen == -1) { + PyMem_FREE(buffer); return NULL; + } if (size != NULL) *size = buflen; return buffer;