summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-08-19 19:52:43 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-08-19 19:52:43 (GMT)
commit8528c3145e5856a88199f07e155b3c75710cc2a1 (patch)
treee9c3fe1341d9888cc06f4f99e0e8ccfcfa268419 /Objects/unicodeobject.c
parenta19de803e4661af947938df2db72d0cd5538f4a4 (diff)
downloadcpython-8528c3145e5856a88199f07e155b3c75710cc2a1.zip
cpython-8528c3145e5856a88199f07e155b3c75710cc2a1.tar.gz
cpython-8528c3145e5856a88199f07e155b3c75710cc2a1.tar.bz2
Issue #15728: Fix leak in PyUnicode_AsWideCharString(). Found by Coverity.
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index d369861..773a9be 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;