summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
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;